This repository has been archived by the owner on Jun 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Static code analysis via Rubocop (#857)
* Add rubocop * Autogenerate rubocop todo yml file * Add rubocop step to CI * Add target version to rubocop config * Fix indentation of "private" macro * Disable all cops by default 👮 * Rubocop: use 1.9 hash syntax * Rubocop add cop for 2 spaces indent * Add cop for case-when indent * Add some more style cops but don't enable them yet * Add and run cop for trailing whitespaces * Add cop for redundant return statements * Add and run cop for redundant "self"s * Add and run cop for redundant parenthesis on method calls * Add and run cops for method def parenthesis * Add descriptions to cops * Add and run cop for blank line around access modifier * Add and run cop to remove random spaces 🚀 * Add and run rubocop for space before comments * Add and run cops for spaces between comma, etc. * Add and run cops for single blank line at the end of files * Add and run cops for class and constant naming * Add and run cop to not unnecessarily nest else in if * Update setup instructions in Readme Add instructions for running code analyzers and some general cleanup. * Update contribution guide to include info about code analyzers [ci skip] * Remove rubocop todo-yml [ci skip] * Revert accidental space-issue * Revert "Revert accidental space-issue" This reverts commit 8034f74. * Fix alignment of if-else in roles_controller * Add and run cops for consistent indentation Also: remove weird spec file that did not do anything. * Add and run cops for if-else alignment * Rephrase change in the contribution guide [ci skip] * Update rubocop docs with 1.8 hash example [ci skip] * Update travis.yml Switch pipeline order: lint before tests close #845
- Loading branch information
1 parent
61315d3
commit db178cf
Showing
112 changed files
with
735 additions
and
531 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
AllCops: | ||
TargetRubyVersion: 2.4 | ||
DisabledByDefault: true | ||
|
||
#################### Layout ############################### | ||
|
||
Layout/AccessModifierIndentation: | ||
Description: Check indentation of private/protected visibility modifiers. | ||
StyleGuide: '#indent-public-private-protected' | ||
Enabled: true | ||
|
||
Layout/InitialIndentation: | ||
Description: >- | ||
Checks the indentation of the first non-blank non-comment line in a file. | ||
Enabled: true | ||
|
||
Layout/IndentationWidth: | ||
Description: "Use 2 spaces for indentation." | ||
StyleGuide: "#spaces-indentation" | ||
Enabled: true | ||
|
||
Layout/IndentationConsistency: | ||
Description: 'Keep indentation straight.' | ||
StyleGuide: '#spaces-indentation' | ||
Enabled: true | ||
|
||
Layout/CaseIndentation: | ||
Description: "Indentation of when in a case/when/[else/]end." | ||
StyleGuide: "#indent-when-to-case" | ||
Enabled: true | ||
|
||
Layout/ElseAlignment: | ||
Description: 'Align elses and elsifs correctly.' | ||
Enabled: true | ||
|
||
Layout/EmptyLinesAroundAccessModifier: | ||
Description: "Keep blank lines around access modifiers." | ||
StyleGuide: "#empty-lines-around-access-modifier" | ||
Enabled: true | ||
|
||
Lint/EndAlignment: | ||
Description: 'Align ends correctly.' | ||
Enabled: true | ||
|
||
Layout/EndOfLine: | ||
Description: "Use Unix-style line endings." | ||
StyleGuide: "#crlf" | ||
Enabled: true | ||
|
||
Layout/ExtraSpacing: | ||
Description: "Do not use unnecessary spacing." | ||
Enabled: true | ||
|
||
Layout/LeadingCommentSpace: | ||
Description: "Comments should start with a space." | ||
StyleGuide: "#hash-space" | ||
Enabled: true | ||
|
||
Layout/SpaceAfterColon: | ||
Description: "Use spaces after colons." | ||
StyleGuide: "#spaces-operators" | ||
Enabled: true | ||
|
||
Layout/SpaceAfterComma: | ||
Description: "Use spaces after commas." | ||
StyleGuide: '#spaces-operators' | ||
Enabled: true | ||
|
||
Layout/SpaceAfterMethodName: | ||
Description: >- | ||
Do not put a space between a method name and the opening | ||
parenthesis in a method definition. | ||
StyleGuide: "#parens-no-spaces" | ||
Enabled: true | ||
|
||
Layout/SpaceAfterNot: | ||
Description: Tracks redundant space after the ! operator. | ||
StyleGuide: "#no-space-bang" | ||
Enabled: true | ||
|
||
Layout/SpaceAfterSemicolon: | ||
Description: "Use spaces after semicolons." | ||
StyleGuide: '#spaces-operators' | ||
Enabled: true | ||
|
||
Layout/SpaceBeforeComma: | ||
Description: "No spaces before commas." | ||
Enabled: true | ||
|
||
Layout/SpaceBeforeComment: | ||
Description: >- | ||
Checks for missing space between code and a comment on the | ||
same line. | ||
Enabled: true | ||
|
||
Layout/SpaceBeforeSemicolon: | ||
Description: "No spaces before semicolons." | ||
Enabled: true | ||
|
||
Layout/SpaceAroundOperators: | ||
Description: "Use a single space around operators." | ||
StyleGuide: "#spaces-operators" | ||
Enabled: true | ||
|
||
Layout/Tab: | ||
Description: "No hard tabs." | ||
StyleGuide: "#spaces-indentation" | ||
Enabled: true | ||
|
||
Layout/TrailingBlankLines: | ||
Description: "Checks trailing blank lines and final newline." | ||
StyleGuide: '#newline-eof' | ||
Enabled: true | ||
|
||
Layout/TrailingWhitespace: | ||
Description: "Avoid trailing whitespace." | ||
StyleGuide: "#no-trailing-whitespace" | ||
Enabled: true | ||
|
||
#################### Naming ############################## | ||
|
||
Naming/ClassAndModuleCamelCase: | ||
Description: "Use CamelCase for classes and modules." | ||
StyleGuide: "#camelcase-classes" | ||
Enabled: true | ||
|
||
Naming/ConstantName: | ||
Description: "Constants should use SCREAMING_SNAKE_CASE." | ||
StyleGuide: "#screaming-snake-case" | ||
Enabled: true | ||
|
||
#################### Style ############################### | ||
|
||
Style/ClassVars: | ||
Description: 'Avoid the use of class variables.' | ||
StyleGuide: '#no-class-vars' | ||
Enabled: true | ||
|
||
Style/DefWithParentheses: | ||
Description: "Use def with parentheses when there are arguments." | ||
StyleGuide: "#method-parens" | ||
Enabled: true | ||
|
||
Style/Encoding: | ||
Description: "Use UTF-8 as the source file encoding." | ||
StyleGuide: "#utf-8" | ||
Enabled: true | ||
|
||
# TODO | ||
Style/FrozenStringLiteralComment: | ||
Description: "Add frozen_string_literal comment to the top of files" | ||
Include: | ||
- "app/**/*.rb" | ||
- "lib/**/*.rb" | ||
Enabled: false | ||
|
||
Style/HashSyntax: | ||
Description: "Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax { :a => 1, :b => 2}" | ||
EnforcedStyle: ruby19 | ||
|
||
Style/IfInsideElse: | ||
Description: "Finds if nodes inside else, which can be converted to elsif." | ||
Enabled: true | ||
|
||
Style/MethodCallWithoutArgsParentheses: | ||
Description: "Do not use parentheses for method calls with no arguments." | ||
StyleGuide: "#method-invocation-parens" | ||
Enabled: true | ||
|
||
Style/MethodDefParentheses: | ||
Description: >- | ||
Checks if the method definitions have or don't have | ||
parentheses. | ||
StyleGuide: "#method-parens" | ||
Enabled: true | ||
|
||
Style/RedundantReturn: | ||
Description: "Don't use return where it's not required." | ||
Enabled: true | ||
|
||
Style/RedundantSelf: | ||
Description: "Don't use self where it's not needed." | ||
Enabled: true | ||
|
||
Style/TrailingCommaInArguments: | ||
Description: "Checks for trailing comma in argument lists." | ||
StyleGuide: "#no-trailing-params-comma" | ||
Enabled: true | ||
|
||
#################### Metrics ############################### | ||
|
||
# TODO | ||
Metrics/LineLength: | ||
Description: "Limit lines to 80 characters." | ||
StyleGuide: "#80-character-limits" | ||
Enabled: false | ||
|
||
|
||
#################### Bundler ############################### | ||
|
||
Bundler/DuplicatedGem: | ||
Description: "Checks for duplicate gem entries in Gemfile." | ||
Enabled: true | ||
Include: | ||
- "**/Gemfile" | ||
- "**/gems.rb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.