diff --git a/.rubocop.yml b/.rubocop.yml index 802a6e67..9c49771d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,9 @@ -inherit_from: ./config/default.yml +inherit_from: + - ./config/default.yml Naming/FileName: Enabled: true Exclude: - "rubocop-github.gemspec" + - "lib/rubocop-github.rb" + - "lib/rubocop-github-rails.rb" diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..7b4ce534 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# rubocop-github + +## Unreleased + +## v0.19.0 + +- Unset `DisabledByDefault: true` in `config/default.yml`. Prevents confusing behaviour where users of the gem didn't realise that RuboCop's default cops weren't being applied (including potentially custom cops in their projects). We've explicitly set `Enabled: false` for all the cops that were previously default disabled. This has the effect that consumers of this gem won't be surprised by new linting violations when they use this new version in their projects. (https://github.com/github/rubocop-github/pull/119) diff --git a/Gemfile.lock b/Gemfile.lock index 41c4de23..e597b511 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - rubocop-github (0.18.0) + rubocop-github (0.19.0) rubocop (>= 1.0.0) rubocop-performance rubocop-rails @@ -31,6 +31,8 @@ GEM crass (~> 1.0.2) nokogiri (>= 1.5.9) minitest (5.16.1) + nokogiri (1.13.6-arm64-darwin) + racc (~> 1.4) nokogiri (1.13.6-x86_64-darwin) racc (~> 1.4) parallel (1.22.1) @@ -71,6 +73,7 @@ GEM unicode-display_width (2.2.0) PLATFORMS + arm64-darwin-21 x86_64-darwin-19 x86_64-darwin-20 diff --git a/README.md b/README.md index 328ed2ba..8796a67d 100644 --- a/README.md +++ b/README.md @@ -4,22 +4,36 @@ This repository provides recommended RuboCop configuration and additional Cops f ## Usage -**Gemfile** +Add `rubocop-github` to your Gemfile, along with its dependencies: -``` ruby -gem "rubocop-github" -gem "rubocop-performance", require: false -gem "rubocop-rails", require: false -``` + ```ruby + gem "rubocop-github", require: false + gem "rubocop-performance", require: false + gem "rubocop-rails", require: false + ``` -**.rubocop.yml** +Inherit all of the stylistic rules and cops through an inheritance declaration in your `.rubocop.yml`: -``` yaml -inherit_gem: - rubocop-github: - - config/default_edge.yml - - config/rails_edge.yml -``` + ```yaml + # .rubocop.yml + inherit_from: + rubocop-github: + - config/default.yml # generic Ruby rules and cops + - config/rails.yml # Rails-specific rules and cops + ``` + +Alternatively, only require the additional custom cops in your `.rubocop.yml` without inheriting/enabling the other stylistic rules: + + ```yaml + # .rubocop.yml + require: + - rubocop-github # generic Ruby cops only + - rubocop-github-rails # Rails-specific cops only + ``` + +💠Looking for `config/accessibility.yml` and the `GitHub/Accessibility` configs? They have been moved to [a new gem](https://github.com/github/rubocop-rails-accessibility). + +For more granular control over which of RuboCop's rules are enabled for your project, both from this gem and your own configs, consider using the `DisabledByDefault: true` option under `AllCops` in your project's `.rubocop.yml` file. This will disable all cops by default, and you can then explicitly enable the ones you want by setting `Enabled: true`. See [the RuboCop docs](https://docs.rubocop.org/rubocop/configuration.html#enabled) for more information. ### Legacy usage @@ -28,9 +42,11 @@ If you are using a rubocop version < 1.0.0, you can use rubocop-github version ## Testing -`bundle install` -`bundle exec rake test` +``` bash +bundle install +bundle exec rake test +``` ## The Cops -All cops are located under [`lib/rubocop/cop/github`](lib/rubocop/cop/github), and contain examples/documentation. +All cops are located under [`lib/rubocop/cop/github`](lib/rubocop/cop/github). diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md index 829f4b2c..1e55a3be 100644 --- a/STYLEGUIDE.md +++ b/STYLEGUIDE.md @@ -1,37 +1,42 @@ # Ruby Style Guide -* Use soft-tabs with a two space indent. - -* Keep each line of code to a readable length. Unless you have a reason to, keep lines to a maximum of 118 characters. Why 118? That's the width at which the pull request diff UI needs horizontal scrolling (making pull requests harder to review). - -* Never leave trailing whitespace. - -* End each file with a [newline](https://github.com/bbatsov/ruby-style-guide#newline-eof). - -* Use spaces around operators, after commas, colons and semicolons, around `{` - and before `}`. - -``` ruby -sum = 1 + 2 -a, b = 1, 2 -1 > 2 ? true : false; puts "Hi" -[1, 2, 3].each { |e| puts e } -``` - -* No spaces after `(`, `[` or before `]`, `)`. - -``` ruby -some(arg).other -[1, 2, 3].length -``` - -* No spaces after `!`. +This is GitHub's Ruby Style Guide, inspired by [RuboCop's guide][rubocop-guide]. + +## Table of Contents +1. [Layout](#layout) + 1. [Indentation](#indentation) + 2. [Inline](#inline) + 3. [Newlines](#newlines) +2. [Maximum Line Length](#line-length) +3. [Classes](#classes) +4. [Collections](#collections) +5. [Documentation](#documentation) +6. [Dynamic Dispatch](#dynamic-dispatch) +7. [Exceptions](#exceptions) +8. [Hashes](#hashes) +9. [Keyword Arguments](#keyword-arguments) +10. [Naming](#naming) +11. [Percent Literals](#percent-literals) +12. [Regular Expressions](#regular-expressions) +13. [Requires](#requires) +14. [Strings](#strings) +15. [Methods](#methods) + 1. [Method definitions](#method-definitions) + 2. [Method calls](#method-calls) +16. [Conditional Expressions](#conditional-expressions) + 1. [Conditional keywords](#conditional-keywords) + 2. [Ternary operator](#ternary-operator) +17. [Syntax](#syntax) + +## Layout + +### Indentation -``` ruby -!array.include?(element) -``` +* Use soft-tabs with a two space indent. + [[link](#default-indentation)] * Indent `when` with the start of the `case` expression. + [[link](#indent-when-as-start-of-case)] ``` ruby # bad @@ -71,8 +76,45 @@ else end ``` +### Inline + +* Never leave trailing whitespace. + [[link](#trailing-whitespace)] + +* Use spaces around operators, after commas, colons and semicolons, around `{` + and before `}`. + [[link](#spaces-operators)] + +``` ruby +sum = 1 + 2 +a, b = 1, 2 +1 > 2 ? true : false; puts "Hi" +[1, 2, 3].each { |e| puts e } +``` + +* No spaces after `(`, `[` or before `]`, `)`. + [[link](#no-spaces-braces)] + +``` ruby +some(arg).other +[1, 2, 3].length +``` + +* No spaces after `!`. + [[link](#no-spaces-bang)] + +``` ruby +!array.include?(element) +``` + +### Newlines + +* End each file with a [newline](https://github.com/bbatsov/ruby-style-guide#newline-eof). + [[link](#newline-eof)] + * Use empty lines between `def`s and to break up a method into logical paragraphs. + [[link](#empty-lines-def)] ``` ruby def some_method @@ -88,10 +130,16 @@ def some_method end ``` +## Maximum Line Length + +* Keep each line of code to a readable length. Unless you have a reason to, keep lines to a maximum of 118 characters. Why 118? That's the width at which the pull request diff UI needs horizontal scrolling (making pull requests harder to review). + [[link](#line-length)] + ## Classes * Avoid the usage of class (`@@`) variables due to their unusual behavior in inheritance. + [[link](#class-variables)] ``` ruby class Parent @@ -115,6 +163,7 @@ Parent.print_class_var # => will print "child" * Use `def self.method` to define singleton methods. This makes the methods more resistant to refactoring changes. + [[link](#singleton-methods)] ``` ruby class TestClass @@ -131,6 +180,7 @@ class TestClass * Avoid `class << self` except when necessary, e.g. single accessors and aliased attributes. + [[link](#class-method-definitions)] ``` ruby class TestClass @@ -163,6 +213,7 @@ end * Indent the `public`, `protected`, and `private` methods as much the method definitions they apply to. Leave one blank line above them. + [[link](#access-modifier-identation)] ``` ruby class SomeClass @@ -179,6 +230,7 @@ end * Avoid explicit use of `self` as the recipient of internal class or instance messages unless to specify a method shadowed by a variable. + [[link](#self-messages)] ``` ruby class SomeClass @@ -195,6 +247,7 @@ end * Prefer `%w` to the literal array syntax when you need an array of strings. + [[link](#percent-w)] ``` ruby # bad @@ -208,8 +261,10 @@ STATES = %w(draft open closed) implements a collection of unordered values with no duplicates. This is a hybrid of `Array`'s intuitive inter-operation facilities and `Hash`'s fast lookup. + [[link](#prefer-set)] * Use symbols instead of strings as hash keys. + [[link](#symbols-as-keys)] ``` ruby # bad @@ -222,6 +277,7 @@ hash = { one: 1, two: 2, three: 3 } ## Documentation Use [TomDoc](http://tomdoc.org) to the best of your ability. It's pretty sweet: +[[link](#tomdoc)] ``` ruby # Public: Duplicate some text an arbitrary number of times. @@ -243,6 +299,7 @@ end ## Dynamic Dispatch Avoid calling `send` and its cousins unless you really need it. Metaprogramming can be extremely powerful, but in most cases you can write code that captures your meaning by being explicit: +[[link](#avoid-send)] ``` ruby # avoid @@ -268,6 +325,7 @@ end ## Exceptions * Don't use exceptions for flow of control. + [[link](#exceptions-flow-control)] ``` ruby # bad @@ -286,6 +344,7 @@ end ``` * Rescue specific exceptions, not `StandardError` or its superclasses. + [[link](#specific-exceptions)] ``` ruby # bad @@ -306,6 +365,7 @@ end ## Hashes Use the Ruby 1.9 syntax for hash literals when all the keys are symbols: +[[link](#symbols-as-hash-keys)] ``` ruby # bad @@ -322,6 +382,7 @@ user = { ``` Use the 1.9 syntax when calling a method with Hash options arguments or named arguments: +[[link](#symbols-as-hash-method-arguments)] ``` ruby # bad @@ -334,6 +395,9 @@ link_to("Account", controller: "users", action: "show", id: user) ``` If you have a hash with mixed key types, use the legacy hashrocket style to avoid mixing styles within the same hash: +[[link](#consistent-hash-syntax)] + +``` ruby ``` ruby # bad @@ -352,8 +416,10 @@ hsh = { ## Keyword Arguments [Keyword arguments](http://magazine.rubyist.net/?Ruby200SpecialEn-kwarg) are recommended but not required when a method's arguments may otherwise be opaque or non-obvious when called. Additionally, prefer them over the old "Hash as pseudo-named args" style from pre-2.0 ruby. +[[link](#keyword-arguments)] So instead of this: + ``` ruby def remove_member(user, skip_membership_check=false) # ... @@ -363,7 +429,8 @@ end remove_member(user, true) ``` -Do this, which is much clearer. +Do this, which is much clearer: + ``` ruby def remove_member(user, skip_membership_check: false) # ... @@ -376,23 +443,29 @@ remove_member(user, skip_membership_check: true) ## Naming * Use `snake_case` for methods and variables. + [[link](#snake-case-methods-vars)] * Use `CamelCase` for classes and modules. (Keep acronyms like HTTP, RFC, XML uppercase.) + [[link](#camelcase-classes-modules)] * Use `SCREAMING_SNAKE_CASE` for other constants. + [[link](#screaming-snake-case-constants)] * The names of predicate methods (methods that return a boolean value) should end in a question mark. (i.e. `Array#empty?`). + [[link](#bool-methods-qmark)] * The names of potentially "dangerous" methods (i.e. methods that modify `self` or the arguments, `exit!`, etc.) should end with an exclamation mark. Bang methods should only exist if a non-bang counterpart (method name which does NOT end with !) also exists. + [[link](#dangerous-method-bang)] ## Percent Literals * Use `%w` freely. + [[link](#use-percent-w-freely)] ``` ruby STATES = %w(draft open closed) @@ -400,6 +473,7 @@ STATES = %w(draft open closed) * Use `%()` for single-line strings which require both interpolation and embedded double-quotes. For multi-line strings, prefer heredocs. + [[link](#percent-parens-single-line)] ``` ruby # bad (no interpolation needed) @@ -419,6 +493,7 @@ STATES = %w(draft open closed) ``` * Use `%r` only for regular expressions matching *more than* one '/' character. + [[link](#percent-r-regular-expressions)] ``` ruby # bad @@ -436,6 +511,7 @@ STATES = %w(draft open closed) * Avoid using $1-9 as it can be hard to track what they contain. Named groups can be used instead. + [[link](#capture-with-named-groups)] ``` ruby # bad @@ -451,6 +527,7 @@ process meaningful_var * Be careful with `^` and `$` as they match start/end of line, not string endings. If you want to match the whole string use: `\A` and `\z`. + [[link](#regex-begin-end-markers)] ``` ruby string = "some injection\nusername" @@ -460,6 +537,7 @@ string[/\Ausername\z/] # don't match * Use `x` modifier for complex regexps. This makes them more readable and you can add some useful comments. Just be careful as spaces are ignored. + [[link](#x-modifier-complex-regex)] ``` ruby regexp = %r{ @@ -476,6 +554,7 @@ regexp = %r{ Always `require` dependencies used directly in a script at the start of the same file. Resources that will get autoloaded on first use—such as Rails models, controllers, or helpers—don't need to be required. +[[link](#require-dependencies-directly)] ``` ruby require "set" @@ -491,6 +570,7 @@ documentation about the libraries that the current file uses. ## Strings * Prefer string interpolation instead of string concatenation: + [[link](#string-interpolation)] ``` ruby # bad @@ -503,6 +583,7 @@ email_with_name = "#{user.name} <#{user.email}>" * Use double-quoted strings. Interpolation and escaped characters will always work without a delimiter change, and `'` is a lot more common than `"` in string literals. + [[link](#double-quotes)] ``` ruby # bad @@ -515,6 +596,7 @@ name = "Bozhidar" * Avoid using `String#+` when you need to construct large data chunks. Instead, use `String#<<`. Concatenation mutates the string instance in-place and is always faster than `String#+`, which creates a bunch of new string objects. + [[link](#string-concatenation)] ``` ruby # good and also fast @@ -526,10 +608,13 @@ paragraphs.each do |paragraph| end ``` -## Syntax +## Methods + +### Method definitions * Use `def` with parentheses when there are arguments. Omit the parentheses when the method doesn't accept any arguments. + [[link](#method-parens-when-arguments)] ``` ruby def some_method @@ -541,25 +626,30 @@ end end ``` -* Never use `for`, unless you know exactly why. Most of the time iterators - should be used instead. `for` is implemented in terms of `each` (so - you're adding a level of indirection), but with a twist - `for` - doesn't introduce a new scope (unlike `each`) and variables defined - in its block will be visible outside it. +### Method calls -``` ruby -arr = [1, 2, 3] +* If the first argument to a method begins with an open parenthesis, + always use parentheses in the method invocation. For example, write + `f((3 + 2) + 1)`. + [[link](#parens-no-spaces)] + +* Never put a space between a method name and the opening parenthesis. + [[link](#no-spaces-method-parens)] +``` ruby # bad -for elem in arr do - puts elem -end +f (3 + 2) + 1 # good -arr.each { |elem| puts elem } +f(3 + 2) + 1 ``` +## Conditional Expressions + +### Conditional keywords + * Never use `then` for multi-line `if/unless`. + [[link](#no-then-for-multi-line-if-unless)] ``` ruby # bad @@ -573,40 +663,12 @@ if some_condition end ``` -* Avoid the ternary operator (`?:`) except in cases where all expressions are extremely - trivial. However, do use the ternary operator(`?:`) over `if/then/else/end` constructs - for single line conditionals. - -``` ruby -# bad -result = if some_condition then something else something_else end - -# good -result = some_condition ? something : something_else -``` - -* Use one expression per branch in a ternary operator. This - also means that ternary operators must not be nested. Prefer - `if/else` constructs in these cases. - -``` ruby -# bad -some_condition ? (nested_condition ? nested_something : nested_something_else) : something_else - -# good -if some_condition - nested_condition ? nested_something : nested_something_else -else - something_else -end -``` - * The `and` and `or` keywords are banned. It's just not worth it. Always use `&&` and `||` instead. - -* Avoid multi-line `?:` (the ternary operator), use `if/unless` instead. + [[link](#no-and-or-or)] * Favor modifier `if/unless` usage when you have a single-line body. + [[link](#favor-modifier-if-unless)] ``` ruby # bad @@ -619,6 +681,7 @@ do_something if some_condition ``` * Never use `unless` with `else`. Rewrite these with the positive case first. + [[link](#no-else-with-unless)] ``` ruby # bad @@ -637,6 +700,7 @@ end ``` * Don't use parentheses around the condition of an `if/unless/while`. + [[link](#no-parens-if-unless-while)] ``` ruby # bad @@ -650,11 +714,68 @@ if x > 10 end ``` +### Ternary operator + +* Avoid the ternary operator (`?:`) except in cases where all expressions are extremely + trivial. However, do use the ternary operator(`?:`) over `if/then/else/end` constructs + for single line conditionals. + [[link](#trivial-ternary)] + +``` ruby +# bad +result = if some_condition then something else something_else end + +# good +result = some_condition ? something : something_else +``` + +* Avoid multi-line `?:` (the ternary operator), use `if/unless` instead. + [[link](#no-multiline-ternary)] + +* Use one expression per branch in a ternary operator. This + also means that ternary operators must not be nested. Prefer + `if/else` constructs in these cases. + [[link](#one-expression-per-branch)] + +``` ruby +# bad +some_condition ? (nested_condition ? nested_something : nested_something_else) : something_else + +# good +if some_condition + nested_condition ? nested_something : nested_something_else +else + something_else +end +``` + +## Syntax + +* Never use `for`, unless you know exactly why. Most of the time iterators + should be used instead. `for` is implemented in terms of `each` (so + you're adding a level of indirection), but with a twist - `for` + doesn't introduce a new scope (unlike `each`) and variables defined + in its block will be visible outside it. + [[link](#avoid-for)] + +``` ruby +arr = [1, 2, 3] + +# bad +for elem in arr do + puts elem +end + +# good +arr.each { |elem| puts elem } +``` + * Prefer `{...}` over `do...end` for single-line blocks. Avoid using `{...}` for multi-line blocks (multiline chaining is always ugly). Always use `do...end` for "control flow" and "method definitions" (e.g. in Rakefiles and certain DSLs). Avoid `do...end` when chaining. + [[link](#squiggly-braces)] ``` ruby names = ["Bozhidar", "Steve", "Sarah"] @@ -676,11 +797,12 @@ names.select do |name| end.map { |name| name.upcase } ``` - Some will argue that multiline chaining would look OK with the use of {...}, but they should - ask themselves - is this code really readable and can't the block's contents be extracted into - nifty methods? +* Some will argue that multiline chaining would look OK with the use of `{...}`, + but they should ask themselves: is this code really readable and can't the block's + contents be extracted into nifty methods? * Avoid `return` where not required. + [[link](#avoid-return)] ``` ruby # bad @@ -695,6 +817,7 @@ end ``` * Use spaces around the `=` operator when assigning default values to method parameters: + [[link](#spaces-around-equals)] ``` ruby # bad @@ -712,6 +835,7 @@ While several Ruby books suggest the first style, the second is much more promin in practice (and arguably a bit more readable). * Using the return value of `=` (an assignment) is ok. + [[link](#use-return-value-of-assignment)] ``` ruby # bad @@ -725,6 +849,7 @@ if (v = next_value) == "hello" ... ``` * Use `||=` freely to initialize variables. + [[link](#memoize-away)] ``` ruby # set name to Bozhidar, only if it's nil or false @@ -733,6 +858,7 @@ name ||= "Bozhidar" * Don't use `||=` to initialize boolean variables. (Consider what would happen if the current value happened to be `false`.) + [[link](#no-memoization-for-boolean)] ``` ruby # bad - would set enabled to true even if it was false @@ -746,22 +872,10 @@ enabled = true if enabled.nil? etc. ). They are quite cryptic and their use in anything but one-liner scripts is discouraged. Prefer long form versions such as `$PROGRAM_NAME`. - -* Never put a space between a method name and the opening parenthesis. - -``` ruby -# bad -f (3 + 2) + 1 - -# good -f(3 + 2) + 1 -``` - -* If the first argument to a method begins with an open parenthesis, - always use parentheses in the method invocation. For example, write -`f((3 + 2) + 1)`. + [[link](#no-cryptic-vars)] * Use `_` for unused block parameters. + [[link](#underscore-unused-vars)] ``` ruby # bad @@ -775,5 +889,8 @@ result = hash.map { |_, v| v + 1 } implementation detail to support Ruby features like `case`, and it's not commutative. For example, `String === "hi"` is true and `"hi" === String` is false. Instead, use `is_a?` or `kind_of?` if you must. + [[link](#type-checking-is-a-kind-of)] Refactoring is even better. It's worth looking hard at any code that explicitly checks types. + +[rubocop-guide]: https://github.com/rubocop-hq/ruby-style-guide diff --git a/config/default.yml b/config/default.yml index 67af72a5..52a0655e 100644 --- a/config/default.yml +++ b/config/default.yml @@ -1,37 +1,187 @@ require: - - rubocop/cop/github + - rubocop-github - rubocop-performance -AllCops: - DisabledByDefault: true - Bundler/DuplicatedGem: Enabled: true +Bundler/GemComment: + Enabled: false + +Bundler/GemFilename: + Enabled: false + +Bundler/GemVersion: + Enabled: false + +Bundler/InsecureProtocolSource: + Enabled: false + Bundler/OrderedGems: Enabled: true +Gemspec/DependencyVersion: + Enabled: false + +Gemspec/DeprecatedAttributeAssignment: + Enabled: false + +Gemspec/DuplicatedAssignment: + Enabled: false + +Gemspec/OrderedDependencies: + Enabled: false + +Gemspec/RequireMFA: + Enabled: false + +Gemspec/RequiredRubyVersion: + Enabled: false + +Gemspec/RubyVersionGlobalsUsage: + Enabled: false + GitHub/InsecureHashAlgorithm: Enabled: true +Layout/AccessModifierIndentation: + Enabled: false + +Layout/ArgumentAlignment: + Enabled: false + +Layout/ArrayAlignment: + Enabled: false + +Layout/AssignmentIndentation: + Enabled: false + +Layout/BeginEndAlignment: + Enabled: false + Layout/BlockAlignment: Enabled: true Layout/BlockEndNewline: Enabled: true +Layout/CaseIndentation: + Enabled: false + +Layout/ClassStructure: + Enabled: false + +Layout/ClosingHeredocIndentation: + Enabled: false + +Layout/ClosingParenthesisIndentation: + Enabled: false + +Layout/CommentIndentation: + Enabled: false + Layout/ConditionPosition: Enabled: true Layout/DefEndAlignment: Enabled: true +Layout/DotPosition: + Enabled: false + +Layout/ElseAlignment: + Enabled: false + +Layout/EmptyComment: + Enabled: false + +Layout/EmptyLineAfterGuardClause: + Enabled: false + +Layout/EmptyLineAfterMagicComment: + Enabled: false + +Layout/EmptyLineAfterMultilineCondition: + Enabled: false + +Layout/EmptyLineBetweenDefs: + Enabled: false + +Layout/EmptyLines: + Enabled: false + +Layout/EmptyLinesAroundAccessModifier: + Enabled: false + +Layout/EmptyLinesAroundArguments: + Enabled: false + +Layout/EmptyLinesAroundAttributeAccessor: + Enabled: false + +Layout/EmptyLinesAroundBeginBody: + Enabled: false + +Layout/EmptyLinesAroundBlockBody: + Enabled: false + +Layout/EmptyLinesAroundClassBody: + Enabled: false + +Layout/EmptyLinesAroundExceptionHandlingKeywords: + Enabled: false + +Layout/EmptyLinesAroundMethodBody: + Enabled: false + +Layout/EmptyLinesAroundModuleBody: + Enabled: false + Layout/EndAlignment: Enabled: false Layout/EndOfLine: Enabled: true +Layout/ExtraSpacing: + Enabled: false + +Layout/FirstArgumentIndentation: + Enabled: false + +Layout/FirstArrayElementIndentation: + Enabled: false + +Layout/FirstArrayElementLineBreak: + Enabled: false + +Layout/FirstHashElementIndentation: + Enabled: false + +Layout/FirstHashElementLineBreak: + Enabled: false + +Layout/FirstMethodArgumentLineBreak: + Enabled: false + +Layout/FirstMethodParameterLineBreak: + Enabled: false + +Layout/FirstParameterIndentation: + Enabled: false + +Layout/HashAlignment: + Enabled: false + +Layout/HeredocArgumentClosingParenthesis: + Enabled: false + +Layout/HeredocIndentation: + Enabled: false + +Layout/IndentationConsistency: + Enabled: false + Layout/IndentationStyle: Enabled: true EnforcedStyle: spaces @@ -44,9 +194,69 @@ Layout/IndentationWidth: Layout/InitialIndentation: Enabled: true +Layout/LeadingCommentSpace: + Enabled: false + +Layout/LeadingEmptyLines: + Enabled: false + +Layout/LineContinuationLeadingSpace: + Enabled: false + +Layout/LineContinuationSpacing: + Enabled: false + +Layout/LineEndStringConcatenationIndentation: + Enabled: false + Layout/LineLength: Enabled: false +Layout/MultilineArrayBraceLayout: + Enabled: false + +Layout/MultilineArrayLineBreaks: + Enabled: false + +Layout/MultilineAssignmentLayout: + Enabled: false + +Layout/MultilineBlockLayout: + Enabled: false + +Layout/MultilineHashBraceLayout: + Enabled: false + +Layout/MultilineHashKeyLineBreaks: + Enabled: false + +Layout/MultilineMethodArgumentLineBreaks: + Enabled: false + +Layout/MultilineMethodCallBraceLayout: + Enabled: false + +Layout/MultilineMethodCallIndentation: + Enabled: false + +Layout/MultilineMethodDefinitionBraceLayout: + Enabled: false + +Layout/MultilineOperationIndentation: + Enabled: false + +Layout/ParameterAlignment: + Enabled: false + +Layout/RedundantLineBreak: + Enabled: false + +Layout/RescueEnsureAlignment: + Enabled: false + +Layout/SingleLineBlockChain: + Enabled: false + Layout/SpaceAfterColon: Enabled: true @@ -68,9 +278,36 @@ Layout/SpaceAroundBlockParameters: Layout/SpaceAroundEqualsInParameterDefault: Enabled: true +Layout/SpaceAroundKeyword: + Enabled: false + +Layout/SpaceAroundMethodCallOperator: + Enabled: false + +Layout/SpaceAroundOperators: + Enabled: false + Layout/SpaceBeforeBlockBraces: Enabled: true +Layout/SpaceBeforeBrackets: + Enabled: false + +Layout/SpaceBeforeComma: + Enabled: false + +Layout/SpaceBeforeComment: + Enabled: false + +Layout/SpaceBeforeFirstArg: + Enabled: false + +Layout/SpaceBeforeSemicolon: + Enabled: false + +Layout/SpaceInLambdaLiteral: + Enabled: false + Layout/SpaceInsideArrayLiteralBrackets: Enabled: true EnforcedStyle: no_space @@ -81,42 +318,129 @@ Layout/SpaceInsideArrayPercentLiteral: Layout/SpaceInsideBlockBraces: Enabled: true +Layout/SpaceInsideHashLiteralBraces: + Enabled: false + Layout/SpaceInsideParens: Enabled: true +Layout/SpaceInsidePercentLiteralDelimiters: + Enabled: false + Layout/SpaceInsideRangeLiteral: Enabled: true Layout/SpaceInsideReferenceBrackets: Enabled: true +Layout/SpaceInsideStringInterpolation: + Enabled: false + Layout/TrailingEmptyLines: Enabled: true Layout/TrailingWhitespace: Enabled: true +Lint/AmbiguousAssignment: + Enabled: false + +Lint/AmbiguousBlockAssociation: + Enabled: false + +Lint/AmbiguousOperator: + Enabled: false + +Lint/AmbiguousOperatorPrecedence: + Enabled: false + +Lint/AmbiguousRange: + Enabled: false + +Lint/AmbiguousRegexpLiteral: + Enabled: false + +Lint/AssignmentInCondition: + Enabled: false + +Lint/BigDecimalNew: + Enabled: false + +Lint/BinaryOperatorWithIdenticalOperands: + Enabled: true + +Lint/BooleanSymbol: + Enabled: false + Lint/CircularArgumentReference: Enabled: true +Lint/ConstantDefinitionInBlock: + Enabled: false + +Lint/ConstantOverwrittenInRescue: + Enabled: false + +Lint/ConstantResolution: + Enabled: false + Lint/Debugger: Enabled: true Lint/DeprecatedClassMethods: Enabled: true -Lint/DuplicateMethods: - Enabled: true +Lint/DeprecatedConstants: + Enabled: false + +Lint/DeprecatedOpenSSLConstant: + Enabled: false + +Lint/DisjunctiveAssignmentInConstructor: + Enabled: false + +Lint/DuplicateBranch: + Enabled: false + +Lint/DuplicateCaseCondition: + Enabled: false + +Lint/DuplicateElsifCondition: + Enabled: false Lint/DuplicateHashKey: Enabled: true +Lint/DuplicateMethods: + Enabled: true + +Lint/DuplicateRegexpCharacterClassElement: + Enabled: false + +Lint/DuplicateRequire: + Enabled: false + +Lint/DuplicateRescueException: + Enabled: false + Lint/EachWithObjectArgument: Enabled: true Lint/ElseLayout: Enabled: true +Lint/EmptyBlock: + Enabled: false + +Lint/EmptyClass: + Enabled: false + +Lint/EmptyInPattern: + Enabled: false + +Lint/EmptyConditionalBody: + Enabled: false + Lint/EmptyEnsure: Enabled: true @@ -129,12 +453,42 @@ Lint/EnsureReturn: Lint/FlipFlop: Enabled: true +Lint/FloatComparison: + Enabled: false + Lint/FloatOutOfRange: Enabled: true Lint/FormatParameterMismatch: Enabled: true +Lint/HashCompareByIdentity: + Enabled: false + +Lint/HeredocMethodCallPosition: + Enabled: false + +Lint/IdentityComparison: + Enabled: false + +Lint/ImplicitStringConcatenation: + Enabled: false + +Lint/IncompatibleIoSelectWithFiberScheduler: + Enabled: false + +Lint/IneffectiveAccessModifier: + Enabled: false + +Lint/InheritException: + Enabled: false + +Lint/InterpolationCheck: + Enabled: false + +Lint/LambdaWithoutLiteralBlock: + Enabled: false + Lint/LiteralAsCondition: Enabled: true @@ -144,39 +498,219 @@ Lint/LiteralInInterpolation: Lint/Loop: Enabled: true -Lint/NextWithoutAccumulator: - Enabled: true +Lint/MissingCopEnableDirective: + Enabled: false -Lint/RandOne: - Enabled: true +Lint/MissingSuper: + Enabled: false -Lint/RequireParentheses: - Enabled: true +Lint/MixedRegexpCaptureTypes: + Enabled: false -Lint/RescueException: - Enabled: true +Lint/MultipleComparison: + Enabled: false -Lint/RedundantStringCoercion: +Lint/NestedMethodDefinition: + Enabled: false + +Lint/NestedPercentLiteral: + Enabled: false + +Lint/NextWithoutAccumulator: Enabled: true -Lint/UnderscorePrefixedVariableName: +Lint/NoReturnInBeginEndBlocks: + Enabled: false + +Lint/NonAtomicFileOperation: + Enabled: false + +Lint/NonDeterministicRequireOrder: + Enabled: false + +Lint/NonLocalExitFromIterator: + Enabled: false + +Lint/NumberConversion: + Enabled: false + +Lint/NumberedParameterAssignment: + Enabled: false + +Lint/OrAssignmentToConstant: + Enabled: false + +Lint/OrderedMagicComments: + Enabled: false + +Lint/OutOfRangeRegexpRef: + Enabled: false + +Lint/ParenthesesAsGroupedExpression: + Enabled: false + +Lint/PercentStringArray: + Enabled: false + +Lint/PercentSymbolArray: + Enabled: false + +Lint/RaiseException: + Enabled: false + +Lint/RandOne: Enabled: true Lint/RedundantCopDisableDirective: Enabled: true +Lint/RedundantCopEnableDirective: + Enabled: false + +Lint/RedundantDirGlobSort: + Enabled: false + +Lint/RedundantRequireStatement: + Enabled: false + +Lint/RedundantSafeNavigation: + Enabled: false + Lint/RedundantSplatExpansion: Enabled: true -Lint/UnreachableCode: +Lint/RedundantStringCoercion: Enabled: true -Lint/BinaryOperatorWithIdenticalOperands: +Lint/RedundantWithIndex: + Enabled: false + +Lint/RedundantWithObject: + Enabled: false + +Lint/RefinementImportMethods: + Enabled: false + +Lint/RegexpAsCondition: + Enabled: false + +Lint/RequireParentheses: + Enabled: true + +Lint/RequireRelativeSelfPath: + Enabled: false + +Lint/RescueException: + Enabled: true + +Lint/RescueType: + Enabled: false + +Lint/ReturnInVoidContext: + Enabled: false + +Lint/SafeNavigationChain: + Enabled: false + +Lint/SafeNavigationConsistency: + Enabled: false + +Lint/SafeNavigationWithEmpty: + Enabled: false + +Lint/ScriptPermission: + Enabled: false + +Lint/SelfAssignment: + Enabled: false + +Lint/SendWithMixinArgument: + Enabled: false + +Lint/ShadowedArgument: + Enabled: false + +Lint/ShadowedException: + Enabled: false + +Lint/ShadowingOuterLocalVariable: + Enabled: false + +Lint/StructNewOverride: + Enabled: false + +Lint/SuppressedException: + Enabled: false + +Lint/SymbolConversion: + Enabled: false + +Lint/ToEnumArguments: + Enabled: false + +Lint/ToJSON: + Enabled: false + +Lint/TopLevelReturnWithArgument: + Enabled: false + +Lint/TrailingCommaInAttributeDeclaration: + Enabled: false + +Lint/TripleQuotes: + Enabled: false + +Lint/UnderscorePrefixedVariableName: + Enabled: true + +Lint/UnexpectedBlockArity: + Enabled: false + +Lint/UnifiedInteger: + Enabled: false + +Lint/UnmodifiedReduceAccumulator: + Enabled: false + +Lint/UnreachableCode: Enabled: true +Lint/UnreachableLoop: + Enabled: false + +Lint/UnusedBlockArgument: + Enabled: false + +Lint/UnusedMethodArgument: + Enabled: false + +Lint/UriEscapeUnescape: + Enabled: false + +Lint/UriRegexp: + Enabled: false + +Lint/UselessAccessModifier: + Enabled: false + +Lint/UselessAssignment: + Enabled: false + +Lint/UselessElseWithoutRescue: + Enabled: false + +Lint/UselessMethodDefinition: + Enabled: false + +Lint/UselessRuby2Keywords: + Enabled: false + Lint/UselessSetterCall: Enabled: true +Lint/UselessTimes: + Enabled: false + Lint/Void: Enabled: true @@ -207,24 +741,111 @@ Metrics/ParameterLists: Metrics/PerceivedComplexity: Enabled: false +Migration/DepartmentName: + Enabled: false + +Naming/AccessorMethodName: + Enabled: false + Naming/AsciiIdentifiers: Enabled: true +Naming/BinaryOperatorParameterName: + Enabled: false + +Naming/BlockForwarding: + Enabled: false + +Naming/BlockParameterName: + Enabled: false + Naming/ClassAndModuleCamelCase: Enabled: true +Naming/ConstantName: + Enabled: false + Naming/FileName: Enabled: true +Naming/HeredocDelimiterCase: + Enabled: false + +Naming/HeredocDelimiterNaming: + Enabled: false + +Naming/InclusiveLanguage: + Enabled: false + +Naming/MemoizedInstanceVariableName: + Enabled: false + Naming/MethodName: Enabled: true +Naming/MethodParameterName: + Enabled: false + +Naming/PredicateName: + Enabled: false + +Naming/RescuedExceptionsVariableName: + Enabled: false + +Naming/VariableName: + Enabled: false + +Naming/VariableNumber: + Enabled: false + +Performance/AncestorsInclude: + Enabled: false + +Performance/ArraySemiInfiniteRangeSlice: + Enabled: false + +Performance/BigDecimalWithNumericArgument: + Enabled: false + +Performance/BindCall: + Enabled: false + +Performance/BlockGivenWithExplicitBlock: + Enabled: false + +Performance/Caller: + Enabled: false + Performance/CaseWhenSplat: Enabled: false +Performance/Casecmp: + Enabled: false + +Performance/ChainArrayAllocation: + Enabled: false + +Performance/CollectionLiteralInLoop: + Enabled: false + +Performance/CompareWithBlock: + Enabled: false + +Performance/ConcurrentMonotonicTime: + Enabled: false + +Performance/ConstantRegexp: + Enabled: false + Performance/Count: Enabled: true +Performance/DeletePrefix: + Enabled: false + +Performance/DeleteSuffix: + Enabled: false + Performance/Detect: Enabled: true @@ -234,12 +855,36 @@ Performance/DoubleStartEndWith: Performance/EndWith: Enabled: true +Performance/FixedSize: + Enabled: false + Performance/FlatMap: Enabled: true +Performance/InefficientHashSearch: + Enabled: false + +Performance/IoReadlines: + Enabled: false + +Performance/MapCompact: + Enabled: false + +Performance/MethodObjectAsBlock: + Enabled: false + +Performance/OpenStruct: + Enabled: false + Performance/RangeInclude: Enabled: false +Performance/RedundantBlockCall: + Enabled: false + +Performance/RedundantEqualityComparisonBlock: + Enabled: false + Performance/RedundantMatch: Enabled: false @@ -247,88 +892,766 @@ Performance/RedundantMerge: Enabled: true MaxKeyValuePairs: 1 +Performance/RedundantSortBlock: + Enabled: false + +Performance/RedundantSplitRegexpArgument: + Enabled: false + +Performance/RedundantStringChars: + Enabled: false + +Performance/RegexpMatch: + Enabled: false + Performance/ReverseEach: Enabled: true +Performance/ReverseFirst: + Enabled: false + +Performance/SelectMap: + Enabled: false + Performance/Size: Enabled: true -Performance/StartWith: - Enabled: true +Performance/SortReverse: + Enabled: false -Security/Eval: - Enabled: true +Performance/Squeeze: + Enabled: false -Style/ArrayJoin: +Performance/StartWith: Enabled: true -Style/BeginBlock: - Enabled: true +Performance/StringIdentifierArgument: + Enabled: false -Style/BlockComments: - Enabled: true +Performance/StringInclude: + Enabled: false -Style/CaseEquality: - Enabled: true +Performance/StringReplacement: + Enabled: false -Style/CharacterLiteral: - Enabled: true +Performance/Sum: + Enabled: false -Style/ClassMethods: - Enabled: true +Performance/TimesMap: + Enabled: false -Style/Copyright: +Performance/UnfreezeString: Enabled: false -Style/DefWithParentheses: - Enabled: true +Performance/UriDefaultParser: + Enabled: false -Style/EndBlock: - Enabled: true +Security/CompoundHash: + Enabled: false -Style/For: +Security/Eval: Enabled: true -Style/FrozenStringLiteralComment: - Enabled: true +Security/IoMethods: + Enabled: false -Style/HashSyntax: - Enabled: true - EnforcedStyle: ruby19_no_mixed_keys +Security/JSONLoad: + Enabled: false + +Security/MarshalLoad: + Enabled: false + +Security/Open: + Enabled: false + +Security/YAMLLoad: + Enabled: false + +Style/AccessModifierDeclarations: + Enabled: false + +Style/AccessorGrouping: + Enabled: false + +Style/Alias: + Enabled: false + +Style/AndOr: + Enabled: false + +Style/ArgumentsForwarding: + Enabled: false + +Style/ArrayCoercion: + Enabled: false + +Style/ArrayJoin: + Enabled: true + +Style/AsciiComments: + Enabled: false + +Style/Attr: + Enabled: false + +Style/AutoResourceCleanup: + Enabled: false + +Style/BarePercentLiterals: + Enabled: false + +Style/BeginBlock: + Enabled: true + +Style/BisectedAttrAccessor: + Enabled: false + +Style/BlockComments: + Enabled: true + +Style/BlockDelimiters: + Enabled: false + +Style/CaseEquality: + Enabled: true + +Style/CaseLikeIf: + Enabled: false + +Style/CharacterLiteral: + Enabled: true + +Style/ClassAndModuleChildren: + Enabled: false + +Style/ClassCheck: + Enabled: false + +Style/ClassEqualityComparison: + Enabled: false + +Style/ClassMethods: + Enabled: true + +Style/ClassMethodsDefinitions: + Enabled: false + +Style/ClassVars: + Enabled: false + +Style/CollectionCompact: + Enabled: false + +Style/CollectionMethods: + Enabled: false + +Style/ColonMethodCall: + Enabled: false + +Style/ColonMethodDefinition: + Enabled: false + +Style/CombinableLoops: + Enabled: false + +Style/CommandLiteral: + Enabled: false + +Style/CommentAnnotation: + Enabled: false + +Style/CommentedKeyword: + Enabled: false + +Style/ConditionalAssignment: + Enabled: false + +Style/ConstantVisibility: + Enabled: false + +Style/Copyright: + Enabled: false + +Style/DateTime: + Enabled: false + +Style/DefWithParentheses: + Enabled: true + +Style/Dir: + Enabled: false + +Style/DisableCopsWithinSourceCodeDirective: + Enabled: false + +Style/DocumentDynamicEvalDefinition: + Enabled: false + +Style/Documentation: + Enabled: false + +Style/DocumentationMethod: + Enabled: false + +Style/DoubleCopDisableDirective: + Enabled: false + +Style/DoubleNegation: + Enabled: false + +Style/EachForSimpleLoop: + Enabled: false + +Style/EachWithObject: + Enabled: false + +Style/EmptyBlockParameter: + Enabled: false + +Style/EmptyCaseCondition: + Enabled: false + +Style/EmptyElse: + Enabled: false + +Style/EmptyLambdaParameter: + Enabled: false + +Style/EmptyLiteral: + Enabled: false + +Style/EmptyMethod: + Enabled: false + +Style/Encoding: + Enabled: false + +Style/EndBlock: + Enabled: true + +Style/EndlessMethod: + Enabled: false + +Style/EnvHome: + Enabled: false + +Style/EvalWithLocation: + Enabled: false + +Style/EvenOdd: + Enabled: false + +Style/ExpandPathArguments: + Enabled: false + +Style/ExplicitBlockArgument: + Enabled: false + +Style/ExponentialNotation: + Enabled: false + +Style/FetchEnvVar: + Enabled: false + +Style/FileRead: + Enabled: false + +Style/FileWrite: + Enabled: false + +Style/FloatDivision: + Enabled: false + +Style/For: + Enabled: true + +Style/FormatString: + Enabled: false + +Style/FormatStringToken: + Enabled: false + +Style/FrozenStringLiteralComment: + Enabled: true + +Style/GlobalStdStream: + Enabled: false + +Style/GlobalVars: + Enabled: false + +Style/GuardClause: + Enabled: false + +Style/HashAsLastArrayItem: + Enabled: false + +Style/HashConversion: + Enabled: false + +Style/HashEachMethods: + Enabled: false + +Style/HashExcept: + Enabled: false + +Style/HashLikeCase: + Enabled: false + +Style/HashSyntax: + Enabled: true + EnforcedStyle: ruby19_no_mixed_keys + +Style/HashTransformKeys: + Enabled: false + +Style/HashTransformValues: + Enabled: false + +Style/IdenticalConditionalBranches: + Enabled: false + +Style/IfInsideElse: + Enabled: false + +Style/IfUnlessModifier: + Enabled: false + +Style/IfUnlessModifierOfIfUnless: + Enabled: false + +Style/IfWithBooleanLiteralBranches: + Enabled: false + +Style/IfWithSemicolon: + Enabled: false + +Style/ImplicitRuntimeError: + Enabled: false + +Style/InPatternThen: + Enabled: false + +Style/InfiniteLoop: + Enabled: false + +Style/InlineComment: + Enabled: false + +Style/InverseMethods: + Enabled: false + +Style/IpAddresses: + Enabled: false + +Style/KeywordParametersOrder: + Enabled: false + +Style/Lambda: + Enabled: false Style/LambdaCall: Enabled: true +Style/LineEndConcatenation: + Enabled: false + +Style/MapCompactWithConditionalBlock: + Enabled: false + +Style/MapToHash: + Enabled: false + +Style/MethodCallWithArgsParentheses: + Enabled: false + Style/MethodCallWithoutArgsParentheses: Enabled: true +Style/MethodCalledOnDoEndBlock: + Enabled: false + Style/MethodDefParentheses: Enabled: true +Style/MinMax: + Enabled: false + +Style/MissingElse: + Enabled: false + +Style/MissingRespondToMissing: + Enabled: false + +Style/MixinGrouping: + Enabled: false + +Style/MixinUsage: + Enabled: false + +Style/ModuleFunction: + Enabled: false + +Style/MultilineBlockChain: + Enabled: false + +Style/MultilineIfModifier: + Enabled: false + Style/MultilineIfThen: Enabled: true +Style/MultilineInPatternThen: + Enabled: false + +Style/MultilineMemoization: + Enabled: false + +Style/MultilineMethodSignature: + Enabled: false + +Style/MultilineTernaryOperator: + Enabled: false + +Style/MultilineWhenThen: + Enabled: false + +Style/MultipleComparison: + Enabled: false + +Style/MutableConstant: + Enabled: false + +Style/NegatedIf: + Enabled: false + +Style/NegatedIfElseCondition: + Enabled: false + +Style/NegatedUnless: + Enabled: false + +Style/NegatedWhile: + Enabled: false + +Style/NestedFileDirname: + Enabled: false + +Style/NestedModifier: + Enabled: false + +Style/NestedParenthesizedCalls: + Enabled: false + +Style/NestedTernaryOperator: + Enabled: false + +Style/Next: + Enabled: false + Style/NilComparison: Enabled: true +Style/NilLambda: + Enabled: false + +Style/NonNilCheck: + Enabled: false + Style/Not: Enabled: true +Style/NumberedParameters: + Enabled: false + +Style/NumberedParametersLimit: + Enabled: false + +Style/NumericLiteralPrefix: + Enabled: false + +Style/NumericLiterals: + Enabled: false + +Style/NumericPredicate: + Enabled: false + +Style/ObjectThen: + Enabled: false + Style/OneLineConditional: Enabled: true +Style/OpenStructUse: + Enabled: false + +Style/OptionHash: + Enabled: false + +Style/OptionalArguments: + Enabled: false + +Style/OptionalBooleanParameter: + Enabled: false + +Style/OrAssignment: + Enabled: false + +Style/ParallelAssignment: + Enabled: false + +Style/ParenthesesAroundCondition: + Enabled: false + +Style/PercentLiteralDelimiters: + Enabled: false + +Style/PercentQLiterals: + Enabled: false + +Style/PerlBackrefs: + Enabled: false + +Style/PreferredHashMethods: + Enabled: false + +Style/Proc: + Enabled: false + +Style/QuotedSymbols: + Enabled: false + +Style/RaiseArgs: + Enabled: false + +Style/RandomWithOffset: + Enabled: false + +Style/RedundantArgument: + Enabled: false + +Style/RedundantAssignment: + Enabled: false + +Style/RedundantBegin: + Enabled: false + +Style/RedundantCapitalW: + Enabled: false + +Style/RedundantCondition: + Enabled: false + +Style/RedundantConditional: + Enabled: false + +Style/RedundantException: + Enabled: false + +Style/RedundantFetchBlock: + Enabled: false + +Style/RedundantFileExtensionInRequire: + Enabled: false + +Style/RedundantFreeze: + Enabled: false + +Style/RedundantInitialize: + Enabled: false + +Style/RedundantInterpolation: + Enabled: false + +Style/RedundantParentheses: + Enabled: false + +Style/RedundantPercentQ: + Enabled: false + +Style/RedundantRegexpCharacterClass: + Enabled: false + +Style/RedundantRegexpEscape: + Enabled: false + +Style/RedundantReturn: + Enabled: false + +Style/RedundantSelf: + Enabled: false + +Style/RedundantSelfAssignment: + Enabled: false + +Style/RedundantSelfAssignmentBranch: + Enabled: false + +Style/RedundantSort: + Enabled: false + Style/RedundantSortBy: Enabled: true +Style/RegexpLiteral: + Enabled: false + +Style/RescueModifier: + Enabled: false + +Style/RescueStandardError: + Enabled: false + +Style/ReturnNil: + Enabled: false + +Style/SafeNavigation: + Enabled: false + Style/Sample: Enabled: true +Style/SelectByRegexp: + Enabled: false + +Style/SelfAssignment: + Enabled: false + +Style/Semicolon: + Enabled: false + +Style/Send: + Enabled: false + +Style/SignalException: + Enabled: false + +Style/SingleArgumentDig: + Enabled: false + +Style/SingleLineBlockParams: + Enabled: false + +Style/SingleLineMethods: + Enabled: false + +Style/SlicingWithRange: + Enabled: false + +Style/SoleNestedConditional: + Enabled: false + +Style/SpecialGlobalVars: + Enabled: false + Style/StabbyLambdaParentheses: Enabled: true -Style/Strip: - Enabled: true +Style/StaticClass: + Enabled: false + +Style/StderrPuts: + Enabled: false + +Style/StringChars: + Enabled: false + +Style/StringConcatenation: + Enabled: false + +Style/StringHashKeys: + Enabled: false Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes + +Style/StringLiteralsInInterpolation: + Enabled: false + +Style/StringMethods: + Enabled: false + +Style/Strip: + Enabled: true + +Style/StructInheritance: + Enabled: false + +Style/SwapValues: + Enabled: false + +Style/SymbolArray: + Enabled: false + +Style/SymbolLiteral: + Enabled: false + +Style/SymbolProc: + Enabled: false + +Style/TernaryParentheses: + Enabled: false + +Style/TopLevelMethodDefinition: + Enabled: false + +Style/TrailingBodyOnClass: + Enabled: false + +Style/TrailingBodyOnMethodDefinition: + Enabled: false + +Style/TrailingBodyOnModule: + Enabled: false + +Style/TrailingCommaInArguments: + Enabled: false + +Style/TrailingCommaInArrayLiteral: + Enabled: false + +Style/TrailingCommaInBlockArgs: + Enabled: false + +Style/TrailingCommaInHashLiteral: + Enabled: false + +Style/TrailingMethodEndStatement: + Enabled: false + +Style/TrailingUnderscoreVariable: + Enabled: false + +Style/TrivialAccessors: + Enabled: false + +Style/UnlessElse: + Enabled: false + +Style/UnlessLogicalOperators: + Enabled: false + +Style/UnpackFirst: + Enabled: false + +Style/VariableInterpolation: + Enabled: false + +Style/WhenThen: + Enabled: false + +Style/WhileUntilDo: + Enabled: false + +Style/WhileUntilModifier: + Enabled: false + +Style/WordArray: + Enabled: false + +Style/YodaCondition: + Enabled: false + +Style/ZeroLengthPredicate: + Enabled: false diff --git a/config/default_cops.yml b/config/default_cops.yml new file mode 100644 index 00000000..00b5ea04 --- /dev/null +++ b/config/default_cops.yml @@ -0,0 +1,3 @@ +GitHub/InsecureHashAlgorithm: + Description: 'Encourage usage of secure hash algorithms' + Enabled: pending diff --git a/config/rails.yml b/config/rails.yml index ab16d61e..e414a00a 100644 --- a/config/rails.yml +++ b/config/rails.yml @@ -1,127 +1,414 @@ require: + - rubocop-github-rails - rubocop-rails -Rails/OutputSafety: - Enabled: true - -Rails/PluralizationGrammar: - Enabled: true - -Rails/RequestReferer: - Enabled: true - EnforcedStyle: referrer - -Rails/ScopeArgs: - Enabled: true - -Rails/UniqBeforePluck: - Enabled: true - GitHub/RailsApplicationRecord: Enabled: true GitHub/RailsControllerRenderActionSymbol: Enabled: true - Include: - - 'app/controllers/**/*.rb' GitHub/RailsControllerRenderLiteral: Enabled: true - StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-render-literal.md - Include: - - 'app/controllers/**/*.rb' GitHub/RailsControllerRenderPathsExist: Enabled: true - ViewPath: - - 'app/views' - Include: - - 'app/controllers/**/*.rb' GitHub/RailsControllerRenderShorthand: Enabled: true - StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-shorthand.md - Include: - - 'app/controllers/**/*.rb' GitHub/RailsRenderInline: Enabled: true - StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-inline.md - Include: - - 'app/controllers/**/*.rb' - - 'app/helpers/**/*.rb' - - 'app/view_models/**/*.rb' - - 'app/views/**/*.erb' GitHub/RailsRenderObjectCollection: Enabled: false GitHub/RailsViewRenderLiteral: Enabled: true - StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-render-literal.md - Include: - - 'app/helpers/**/*.rb' - - 'app/view_models/**/*.rb' - - 'app/views/**/*.erb' GitHub/RailsViewRenderPathsExist: Enabled: true - ViewPath: - - 'app/views' - Include: - - 'app/helpers/**/*.rb' - - 'app/view_models/**/*.rb' - - 'app/views/**/*.erb' GitHub/RailsViewRenderShorthand: Enabled: true - Include: - - 'app/helpers/**/*.rb' - - 'app/view_models/**/*.rb' - - 'app/views/**/*.erb' - -# Exclude Rails ERB files from incompatible cops Layout/BlockAlignment: Exclude: - - 'app/views/**/*.erb' + - app/views/**/*.erb -Style/For: - Exclude: - - 'app/views/**/*.erb' - -Style/OneLineConditional: +Layout/IndentationWidth: Exclude: - - 'app/views/**/*.erb' + - app/views/**/*.erb -Style/Semicolon: +Layout/InitialIndentation: Exclude: - - 'app/views/**/*.erb' + - app/views/**/*.erb Layout/SpaceInsideParens: Exclude: - - 'app/views/**/*.erb' - -Style/StringLiterals: - Exclude: - - 'app/views/**/*.erb' + - app/views/**/*.erb Layout/TrailingEmptyLines: Exclude: - - 'app/views/**/*.erb' + - app/views/**/*.erb Layout/TrailingWhitespace: Exclude: - - 'app/views/**/*.erb' + - app/views/**/*.erb -Layout/IndentationWidth: +Lint/UselessAccessModifier: + ContextCreatingMethods: + - concerning + +Rails/ActionControllerTestCase: + Enabled: false + +Rails/ActionFilter: + Enabled: false + +Rails/ActiveRecordAliases: + Enabled: false + +Rails/ActiveRecordCallbacksOrder: + Enabled: false + +Rails/ActiveRecordOverride: + Enabled: false + +Rails/ActiveSupportAliases: + Enabled: false + +Rails/AddColumnIndex: + Enabled: false + +Rails/AfterCommitOverride: + Enabled: false + +Rails/ApplicationController: + Enabled: false + +Rails/ApplicationJob: + Enabled: false + +Rails/ApplicationMailer: + Enabled: false + +Rails/ApplicationRecord: + Enabled: false + +Rails/ArelStar: + Enabled: false + +Rails/AssertNot: + Enabled: false + +Rails/AttributeDefaultBlockValue: + Enabled: false + +Rails/BelongsTo: + Enabled: false + +Rails/Blank: + Enabled: false + +Rails/BulkChangeTable: + Enabled: false + +Rails/CompactBlank: + Enabled: false + +Rails/ContentTag: + Enabled: false + +Rails/CreateTableWithTimestamps: + Enabled: false + +Rails/Date: + Enabled: false + +Rails/DefaultScope: + Enabled: false + +Rails/Delegate: + Enabled: false + +Rails/DelegateAllowBlank: + Enabled: false + +Rails/DeprecatedActiveModelErrorsMethods: + Enabled: false + +Rails/DotSeparatedKeys: + Enabled: false + +Rails/DuplicateAssociation: + Enabled: false + +Rails/DuplicateScope: + Enabled: false + +Rails/DurationArithmetic: + Enabled: false + +Rails/DynamicFindBy: + Enabled: false + +Rails/EagerEvaluationLogMessage: + Enabled: false + +Rails/EnumHash: + Enabled: false + +Rails/EnumUniqueness: + Enabled: false + +Rails/EnvironmentComparison: + Enabled: false + +Rails/EnvironmentVariableAccess: + Enabled: false + +Rails/Exit: + Enabled: false + +Rails/ExpandedDateRange: + Enabled: false + +Rails/FilePath: + Enabled: false + +Rails/FindBy: + Enabled: false + +Rails/FindById: + Enabled: false + +Rails/FindEach: + Enabled: false + +Rails/HasAndBelongsToMany: + Enabled: false + +Rails/HasManyOrHasOneDependent: + Enabled: false + +Rails/HelperInstanceVariable: + Enabled: false + +Rails/HttpPositionalArguments: + Enabled: false + +Rails/HttpStatus: + Enabled: false + +Rails/I18nLazyLookup: + Enabled: false + +Rails/I18nLocaleAssignment: + Enabled: false + +Rails/I18nLocaleTexts: + Enabled: false + +Rails/IgnoredSkipActionFilterOption: + Enabled: false + +Rails/IndexBy: + Enabled: false + +Rails/IndexWith: + Enabled: false + +Rails/Inquiry: + Enabled: false + +Rails/InverseOf: + Enabled: false + +Rails/LexicallyScopedActionFilter: + Enabled: false + +Rails/LinkToBlank: + Enabled: false + +Rails/MailerName: + Enabled: false + +Rails/MatchRoute: + Enabled: false + +Rails/MigrationClassName: + Enabled: false + +Rails/NegateInclude: + Enabled: false + +Rails/NotNullColumn: + Enabled: false + +Rails/OrderById: + Enabled: false + +Rails/Output: + Enabled: false + +Rails/OutputSafety: + Enabled: true + +Rails/Pick: + Enabled: false + +Rails/Pluck: + Enabled: false + +Rails/PluckId: + Enabled: false + +Rails/PluckInWhere: + Enabled: false + +Rails/PluralizationGrammar: + Enabled: true + +Rails/Presence: + Enabled: false + +Rails/Present: + Enabled: false + +Rails/RakeEnvironment: + Enabled: false + +Rails/ReadWriteAttribute: + Enabled: false + +Rails/RedundantAllowNil: + Enabled: false + +Rails/RedundantForeignKey: + Enabled: false + +Rails/RedundantPresenceValidationOnBelongsTo: + Enabled: false + +Rails/RedundantReceiverInWithOptions: + Enabled: false + +Rails/RedundantTravelBack: + Enabled: false + +Rails/ReflectionClassName: + Enabled: false + +Rails/RefuteMethods: + Enabled: false + +Rails/RelativeDateConstant: + Enabled: false + +Rails/RenderInline: + Enabled: false + +Rails/RenderPlainText: + Enabled: false + +Rails/RequestReferer: + Enabled: true + EnforcedStyle: referrer + +Rails/RequireDependency: + Enabled: false + +Rails/ReversibleMigration: + Enabled: false + +Rails/ReversibleMigrationMethodDefinition: + Enabled: false + +Rails/RootJoinChain: + Enabled: false + +Rails/RootPublicPath: + Enabled: false + +Rails/SafeNavigation: + Enabled: false + +Rails/SafeNavigationWithBlank: + Enabled: false + +Rails/SaveBang: + Enabled: false + +Rails/SchemaComment: + Enabled: false + +Rails/ScopeArgs: + Enabled: true + +Rails/ShortI18n: + Enabled: false + +Rails/SkipsModelValidations: + Enabled: false + +Rails/SquishedSQLHeredocs: + Enabled: false + +Rails/StripHeredoc: + Enabled: false + +Rails/TableNameAssignment: + Enabled: false + +Rails/TimeZone: + Enabled: false + +Rails/TimeZoneAssignment: + Enabled: false + +Rails/ToFormattedS: + Enabled: false + +Rails/TransactionExitStatement: + Enabled: false + +Rails/UniqBeforePluck: + Enabled: true + +Rails/UniqueValidationWithoutIndex: + Enabled: false + +Rails/UnknownEnv: + Enabled: false + +Rails/UnusedIgnoredColumns: + Enabled: false + +Rails/Validation: + Enabled: false + +Rails/WhereEquals: + Enabled: false + +Rails/WhereExists: + Enabled: false + +Rails/WhereNot: + Enabled: false + +Style/For: Exclude: - - 'app/views/**/*.erb' + - app/views/**/*.erb -Layout/InitialIndentation: +Style/OneLineConditional: Exclude: - - 'app/views/**/*.erb' + - app/views/**/*.erb -Lint/UselessAccessModifier: - ContextCreatingMethods: - - concerning +Style/Semicolon: + Exclude: + - app/views/**/*.erb + +Style/StringLiterals: + Exclude: + - app/views/**/*.erb diff --git a/config/rails_cops.yml b/config/rails_cops.yml new file mode 100644 index 00000000..ef3d9a4f --- /dev/null +++ b/config/rails_cops.yml @@ -0,0 +1,62 @@ +GitHub/RailsApplicationRecord: + Enabled: pending + +GitHub/RailsControllerRenderActionSymbol: + Enabled: pending + Include: + - 'app/controllers/**/*.rb' + +GitHub/RailsControllerRenderLiteral: + Enabled: pending + StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-render-literal.md + Include: + - 'app/controllers/**/*.rb' + +GitHub/RailsControllerRenderPathsExist: + Enabled: pending + ViewPath: + - 'app/views' + Include: + - 'app/controllers/**/*.rb' + +GitHub/RailsControllerRenderShorthand: + Enabled: pending + StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-shorthand.md + Include: + - 'app/controllers/**/*.rb' + +GitHub/RailsRenderInline: + Enabled: pending + StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-inline.md + Include: + - 'app/controllers/**/*.rb' + - 'app/helpers/**/*.rb' + - 'app/view_models/**/*.rb' + - 'app/views/**/*.erb' + +GitHub/RailsRenderObjectCollection: + Enabled: pending + +GitHub/RailsViewRenderLiteral: + Enabled: pending + StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-render-literal.md + Include: + - 'app/helpers/**/*.rb' + - 'app/view_models/**/*.rb' + - 'app/views/**/*.erb' + +GitHub/RailsViewRenderPathsExist: + Enabled: pending + ViewPath: + - 'app/views' + Include: + - 'app/helpers/**/*.rb' + - 'app/view_models/**/*.rb' + - 'app/views/**/*.erb' + +GitHub/RailsViewRenderShorthand: + Enabled: pending + Include: + - 'app/helpers/**/*.rb' + - 'app/view_models/**/*.rb' + - 'app/views/**/*.erb' diff --git a/lib/rubocop-github-rails.rb b/lib/rubocop-github-rails.rb new file mode 100644 index 00000000..02aa6adc --- /dev/null +++ b/lib/rubocop-github-rails.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require "rubocop" +require "rubocop/github" +require "rubocop/github/inject" + +RuboCop::GitHub::Inject.rails_defaults! + +require "rubocop/cop/github/rails_application_record" +require "rubocop/cop/github/rails_controller_render_action_symbol" +require "rubocop/cop/github/rails_controller_render_literal" +require "rubocop/cop/github/rails_controller_render_paths_exist" +require "rubocop/cop/github/rails_controller_render_shorthand" +require "rubocop/cop/github/rails_render_inline" +require "rubocop/cop/github/rails_render_object_collection" +require "rubocop/cop/github/rails_view_render_literal" +require "rubocop/cop/github/rails_view_render_paths_exist" +require "rubocop/cop/github/rails_view_render_shorthand" diff --git a/lib/rubocop-github.rb b/lib/rubocop-github.rb new file mode 100644 index 00000000..17c07e77 --- /dev/null +++ b/lib/rubocop-github.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require "rubocop" +require "rubocop/github" +require "rubocop/github/inject" + +RuboCop::GitHub::Inject.default_defaults! + +require "rubocop/cop/github/insecure_hash_algorithm" diff --git a/lib/rubocop/cop/github.rb b/lib/rubocop/cop/github.rb index e978c2b9..fa55c2d2 100644 --- a/lib/rubocop/cop/github.rb +++ b/lib/rubocop/cop/github.rb @@ -1,13 +1,4 @@ # frozen_string_literal: true -require "rubocop/cop/github/insecure_hash_algorithm" -require "rubocop/cop/github/rails_application_record" -require "rubocop/cop/github/rails_controller_render_action_symbol" -require "rubocop/cop/github/rails_controller_render_literal" -require "rubocop/cop/github/rails_controller_render_paths_exist" -require "rubocop/cop/github/rails_controller_render_shorthand" -require "rubocop/cop/github/rails_render_inline" -require "rubocop/cop/github/rails_render_object_collection" -require "rubocop/cop/github/rails_view_render_literal" -require "rubocop/cop/github/rails_view_render_paths_exist" -require "rubocop/cop/github/rails_view_render_shorthand" +require "rubocop-github" +require "rubocop-rails" diff --git a/lib/rubocop/github.rb b/lib/rubocop/github.rb new file mode 100644 index 00000000..d367f815 --- /dev/null +++ b/lib/rubocop/github.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module RuboCop + module GitHub + PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze + CONFIG_DEFAULT = PROJECT_ROOT.join("config", "default_cops.yml").freeze + CONFIG_RAILS = PROJECT_ROOT.join("config", "rails_cops.yml").freeze + end +end diff --git a/lib/rubocop/github/inject.rb b/lib/rubocop/github/inject.rb new file mode 100644 index 00000000..697a5809 --- /dev/null +++ b/lib/rubocop/github/inject.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module RuboCop + module GitHub + # Because RuboCop doesn't yet support plugins, we have to monkey patch in a + # bit of our configuration. Borrowed from: + # https://github.com/rubocop/rubocop-rails/blob/f36121946359615a26c9a941763abd1470693e8d/lib/rubocop/rails/inject.rb + module Inject + def self.default_defaults! + _load_config(CONFIG_DEFAULT) + end + + def self.rails_defaults! + _load_config(CONFIG_RAILS) + end + + def self._load_config(path) + path = path.to_s + hash = ConfigLoader.send(:load_yaml_configuration, path) + config = Config.new(hash, path).tap(&:make_excludes_absolute) + puts "configuration from #{path}" if ConfigLoader.debug? + config = ConfigLoader.merge_with_default(config, path, unset_nil: false) + ConfigLoader.instance_variable_set(:@default_configuration, config) + end + end + end +end diff --git a/rubocop-github.gemspec b/rubocop-github.gemspec index d18c7205..7b243dd4 100644 --- a/rubocop-github.gemspec +++ b/rubocop-github.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = "rubocop-github" - s.version = "0.18.0" + s.version = "0.19.0" s.summary = "RuboCop GitHub" s.description = "Code style checking for GitHub Ruby repositories " s.homepage = "https://github.com/github/rubocop-github"
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: