Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RoR Linters #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
# linters
# Convose Linters Config

## Linter config for:
- [Ruby on Rails](./ruby-on-rails)
- [React.js](./react)

Follow those instructions in order to set up linters or validators in your repo.
Empty file added react/.eslintrc.json
Empty file.
22 changes: 22 additions & 0 deletions ruby-on-rails/.github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Linters

on: pull_request

env:
FORCE_COLOR: 1

jobs:
rubocop:
name: Rubocop
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Setup Rubocop
run: |
gem install --no-document rubocop -v '>= 1.0, < 2.0' # https://docs.rubocop.org/en/stable/installation/
[ -f .rubocop.yml ] || wget https://raw.githubusercontent.com/convose1/linters/dev/ruby-on-rails/.rubocop.yml
- name: Rubocop Report
run: rubocop --color
61 changes: 61 additions & 0 deletions ruby-on-rails/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
AllCops:
TargetRubyVersion: 2.6
NewCops: enable
Exclude:
- "db/**/*"
- "bin/*"
- "config/**/*"
- "Guardfile"
- "Rakefile"
- "node_modules/**/*"

DisplayCopNames: true

Layout/LineLength:
Max: 150
Metrics/MethodLength:
Include:
- "app/controllers/*"
- "app/models/*"
Max: 20
Metrics/AbcSize:
Include:
- "app/controllers/*"
- "app/models/*"
Max: 50
Metrics/ClassLength:
Max: 150
Metrics/BlockLength:
IgnoredMethods: ["describe"]
Max: 30

Style/Documentation:
Enabled: false
Style/ClassAndModuleChildren:
Enabled: false
Style/EachForSimpleLoop:
Enabled: false
Style/AndOr:
Enabled: false
Style/DefWithParentheses:
Enabled: false
Style/FrozenStringLiteralComment:
EnforcedStyle: never

Layout/HashAlignment:
EnforcedColonStyle: key
Layout/ExtraSpacing:
AllowForAlignment: false
Layout/MultilineMethodCallIndentation:
Enabled: true
EnforcedStyle: indented
Lint/RaiseException:
Enabled: false
Lint/StructNewOverride:
Enabled: false
Style/HashEachMethods:
Enabled: false
Style/HashTransformKeys:
Enabled: false
Style/HashTransformValues:
Enabled: false
27 changes: 27 additions & 0 deletions ruby-on-rails/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Ruby on Rails Linters

If you are not familiar with linters and GitHub Actions, read [root level README](../README.md).

## Set-up GitHub Actions


This GitHub Action is going to run [Rubocop](https://docs.rubocop.org/en/stable/) to help you find style/linter issues.

[Rubocop](https://docs.rubocop.org/en/stable/) is a Ruby static code analyzer (a.k.a. linter) and code formatter. It will enforce many of the guidelines outlined in the community [Ruby Style Guide](https://rubystyle.guide/).

Please do the following **steps in this order**:

1. In the first commit of your feature branch create a `.github/workflows` folder and add a copy of [`.github/workflows/linters.yml`](.github/workflows/linters.yml) to that folder.
2. When you open your first pull request you should see the result of the GitHub Actions.
3. Click on the `Details` link to see the full output and the errors that need to be fixed.

## Set-up linters in your local env

1. Add this line to the `Gemfile`
```
gem 'rubocop', '>= 1.0', '< 2.0'
```
2. Run `bundle install`.
3. Copy [.rubocop.yml](./.rubocop.yml) to the root directory of your project
5. Run `rubocop`.
6. Fix linter errors `rubocop --fix`.