config/upstream.yml in cookstyle-2.1.0 vs config/upstream.yml in cookstyle-3.0.0

- old
+ new

@@ -7,12 +7,15 @@ # Common configuration. AllCops: # Include common Ruby source files. Include: + - '**/*.arb' + - '**/*.axlsx' - '**/*.builder' - '**/*.fcgi' + - '**/*.gemfile' - '**/*.gemspec' - '**/*.god' - '**/*.jb' - '**/*.jbuilder' - '**/*.mspec' @@ -53,17 +56,19 @@ - '**/Snapfile' - '**/Thorfile' - '**/Vagabondfile' - '**/Vagrantfile' Exclude: + - 'node_modules/**/*' - 'vendor/**/*' + - '.git/**/*' # Default formatter will be used if no `-f/--format` option is given. DefaultFormatter: progress - # Cop names are not displayed in offense messages by default. Change behavior - # by overriding DisplayCopNames, or by giving the `-D/--display-cop-names` + # Cop names are displayed in offense messages by default. Change behavior + # by overriding DisplayCopNames, or by giving the `--no-display-cop-names` # option. - DisplayCopNames: false + DisplayCopNames: true # Style guide URLs are not displayed in offense messages by default. Change # behavior by overriding `DisplayStyleGuide`, or by giving the # `-S/--display-style-guide` option. DisplayStyleGuide: false # When specifying style guide URLs, any paths and/or fragments will be @@ -108,15 +113,28 @@ # this kind of attack, and wish to use a symlinked cache location, set this # value to "true". AllowSymlinksInCacheRootDirectory: false # What MRI version of the Ruby interpreter is the inspected code intended to # run on? (If there is more than one, set this to the lowest version.) - # If a value is specified for TargetRubyVersion then it is used. - # Else if .ruby-version exists and it contains an MRI version it is used. - # Otherwise we fallback to the oldest officially supported Ruby version (2.1). + # If a value is specified for TargetRubyVersion then it is used. Acceptable + # values are specificed as a float (i.e. 2.5); the teeny version of Ruby + # should not be included. If the project specifies a Ruby version in the + # .ruby-version file, Gemfile or gems.rb file, RuboCop will try to determine + # the desired version of Ruby by inspecting the .ruby-version file first, + # followed by the Gemfile.lock or gems.locked file. (Although the Ruby version + # is specified in the Gemfile or gems.rb file, RuboCop reads the final value + # from the lock file.) If the Ruby version is still unresolved, RuboCop will + # use the oldest officially supported Ruby version (currently Ruby 2.1). TargetRubyVersion: ~ - TargetRailsVersion: 5.0 + # What version of Rails is the inspected code using? If a value is specified + # for TargetRailsVersion then it is used. Acceptable values are specificed + # as a float (i.e. 5.1); the patch version of Rails should not be included. + # If TargetRailsVersion is not set, RuboCop will parse the Gemfile.lock or + # gems.locked file to find the version of Rails that has been bound to the + # application. If neither of those files exist, RuboCop will use Rails 5.0 + # as the default. + TargetRailsVersion: ~ #################### Layout ########################### # Indent private/protected/public as deep as method definitions Layout/AccessModifierIndentation: @@ -220,10 +238,23 @@ - with_fixed_indentation # By default, the indentation width from Layout/IndentationWidth is used # But it can be overridden by setting this parameter IndentationWidth: ~ +# checks whether the end keywords are aligned properly for `do` `end` blocks. +Layout/BlockAlignment: + # The value `start_of_block` means that the `end` should be aligned with line + # where the `do` keyword appears. + # The value `start_of_line` means it should be aligned with the whole + # expression's starting line. + # The value `either` means both are allowed. + EnforcedStyleAlignWith: either + SupportedStylesAlignWith: + - either + - start_of_block + - start_of_line + # Indentation of `when`. Layout/CaseIndentation: EnforcedStyle: case SupportedStyles: - case @@ -232,17 +263,33 @@ # By default, the indentation width from `Layout/IndentationWidth` is used. # But it can be overridden by setting this parameter. # This only matters if `IndentOneStep` is `true` IndentationWidth: ~ +Layout/DefEndAlignment: + # The value `def` means that `end` should be aligned with the def keyword. + # The value `start_of_line` means that `end` should be aligned with method + # calls like `private`, `public`, etc, if present in front of the `def` + # keyword on the same line. + EnforcedStyleAlignWith: start_of_line + SupportedStylesAlignWith: + - start_of_line + - def + AutoCorrect: false + Severity: warning + # Multi-line method chaining should be done with leading dots. Layout/DotPosition: EnforcedStyle: leading SupportedStyles: - leading - trailing +Layout/EmptyComment: + AllowBorderComment: true + AllowMarginComment: true + # Use empty lines between defs. Layout/EmptyLineBetweenDefs: # If `true`, this parameter means that single line method definitions don't # need an empty line between them. AllowAdjacentOneLineDefs: false @@ -260,19 +307,38 @@ SupportedStyles: - empty_lines - empty_lines_except_namespace - empty_lines_special - no_empty_lines + - beginning_only + - ending_only Layout/EmptyLinesAroundModuleBody: EnforcedStyle: no_empty_lines SupportedStyles: - empty_lines - empty_lines_except_namespace - empty_lines_special - no_empty_lines +# Align ends correctly. +Layout/EndAlignment: + # The value `keyword` means that `end` should be aligned with the matching + # keyword (`if`, `while`, etc.). + # The value `variable` means that in assignments, `end` should be aligned + # with the start of the variable on the left hand side of `=`. In all other + # situations, `end` should still be aligned with the keyword. + # The value `start_of_line` means that `end` should be aligned with the start + # of the line which the matching keyword appears on. + EnforcedStyleAlignWith: keyword + SupportedStylesAlignWith: + - keyword + - variable + - start_of_line + AutoCorrect: false + Severity: warning + Layout/EndOfLine: # The `native` style means that CR+LF (Carriage Return + Line Feed) is # enforced on Windows, and LF is enforced on other platforms. The other styles # mean LF and CR+LF, respectively. EnforcedStyle: native @@ -487,17 +553,34 @@ Layout/SpaceBeforeBlockBraces: EnforcedStyle: space SupportedStyles: - space - no_space + EnforcedStyleForEmptyBraces: space + SupportedStylesForEmptyBraces: + - space + - no_space Layout/SpaceBeforeFirstArg: # When `true`, allows most uses of extra spacing if the intent is to align # things with the previous or next line, not counting empty lines or comment # lines. AllowForAlignment: true +Layout/SpaceInsideArrayLiteralBrackets: + EnforcedStyle: no_space + SupportedStyles: + - space + - no_space + # 'compact' normally requires a space inside the brackets, with the exception + # that successive left brackets or right brackets are collapsed together + - compact + EnforcedStyleForEmptyBrackets: no_space + SupportedStylesForEmptyBrackets: + - space + - no_space + Layout/SpaceInsideBlockBraces: EnforcedStyle: space SupportedStyles: - space - no_space @@ -519,22 +602,203 @@ EnforcedStyleForEmptyBraces: no_space SupportedStylesForEmptyBraces: - space - no_space +Layout/SpaceInsideParens: + EnforcedStyle: no_space + SupportedStyles: + - space + - no_space + +Layout/SpaceInsideReferenceBrackets: + EnforcedStyle: no_space + SupportedStyles: + - space + - no_space + EnforcedStyleForEmptyBrackets: no_space + SupportedStylesForEmptyBrackets: + - space + - no_space + Layout/SpaceInsideStringInterpolation: EnforcedStyle: no_space SupportedStyles: - space - no_space +Layout/ClassStructure: + Categories: + module_inclusion: + - include + - prepend + - extend + ExpectedOrder: + - module_inclusion + - constants + - public_class_methods + - initializer + - public_methods + - protected_methods + - private_methods + +Layout/Tab: + # By default, the indentation width from Layout/IndentationWidth is used + # But it can be overridden by setting this parameter + # It is used during auto-correction to determine how many spaces should + # replace each tab. + IndentationWidth: ~ + Layout/TrailingBlankLines: EnforcedStyle: final_newline SupportedStyles: - final_newline - final_blank_line +Layout/TrailingWhitespace: + AllowInHeredoc: false + +#################### Naming ########################## + +Naming/FileName: + # File names listed in `AllCops:Include` are excluded by default. Add extra + # excludes here. + Exclude: [] + # When `true`, requires that each source file should define a class or module + # with a name which matches the file name (converted to ... case). + # It further expects it to be nested inside modules which match the names + # of subdirectories in its path. + ExpectMatchingDefinition: false + # If non-`nil`, expect all source file names to match the following regex. + # Only the file name itself is matched, not the entire file path. + # Use anchors as necessary if you want to match the entire name rather than + # just a part of it. + Regex: ~ + # With `IgnoreExecutableScripts` set to `true`, this cop does not + # report offending filenames for executable scripts (i.e. source + # files with a shebang in the first line). + IgnoreExecutableScripts: true + AllowedAcronyms: + - CLI + - DSL + - ACL + - API + - ASCII + - CPU + - CSS + - DNS + - EOF + - GUID + - HTML + - HTTP + - HTTPS + - ID + - IP + - JSON + - LHS + - QPS + - RAM + - RHS + - RPC + - SLA + - SMTP + - SQL + - SSH + - TCP + - TLS + - TTL + - UDP + - UI + - UID + - UUID + - URI + - URL + - UTF8 + - VM + - XML + - XMPP + - XSRF + - XSS + +Naming/HeredocDelimiterNaming: + Blacklist: + - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/' + +Naming/HeredocDelimiterCase: + EnforcedStyle: uppercase + SupportedStyles: + - lowercase + - uppercase + +Naming/MethodName: + EnforcedStyle: snake_case + SupportedStyles: + - snake_case + - camelCase + +Naming/PredicateName: + # Predicate name prefixes. + NamePrefix: + - is_ + - has_ + - have_ + # Predicate name prefixes that should be removed. + NamePrefixBlacklist: + - is_ + - has_ + - have_ + # Predicate names which, despite having a blacklisted prefix, or no `?`, + # should still be accepted + NameWhitelist: + - is_a? + # Method definition macros for dynamically generated methods. + MethodDefinitionMacros: + - define_method + - define_singleton_method + # Exclude Rspec specs because there is a strong convention to write spec + # helpers in the form of `have_something` or `be_something`. + Exclude: + - 'spec/**/*' + +Naming/UncommunicativeBlockParamName: + # Parameter names may be equal to or greater than this value + MinNameLength: 1 + AllowNamesEndingInNumbers: true + # Whitelisted names that will not register an offense + AllowedNames: [] + # Blacklisted names that will register an offense + ForbiddenNames: [] + +Naming/UncommunicativeMethodParamName: + # Parameter names may be equal to or greater than this value + MinNameLength: 3 + AllowNamesEndingInNumbers: true + # Whitelisted names that will not register an offense + AllowedNames: + - io + - id + - to + - by + - 'on' + - in + - at + # Blacklisted names that will register an offense + ForbiddenNames: [] + +Naming/VariableName: + EnforcedStyle: snake_case + SupportedStyles: + - snake_case + - camelCase + +Naming/VariableNumber: + EnforcedStyle: normalcase + SupportedStyles: + - snake_case + - normalcase + - non_integer + #################### Style ########################### Style/Alias: EnforcedStyle: prefer_alias SupportedStyles: @@ -547,10 +811,13 @@ EnforcedStyle: always SupportedStyles: - always - conditionals +Style/AsciiComments: + AllowedChars: [] + # Checks if usage of `%()` or `%Q()` matches configuration. Style/BarePercentLiterals: EnforcedStyle: bare_percent SupportedStyles: - percent_q @@ -760,87 +1027,16 @@ EnforcedStyle: compact SupportedStyles: - compact - expanded -# Checks whether the source file has a utf-8 encoding comment or not -# AutoCorrectEncodingComment must match the regex -# /#.*coding\s?[:=]\s?(?:UTF|utf)-8/ -Style/Encoding: - EnforcedStyle: never - SupportedStyles: - - when_needed - - always - - never - AutoCorrectEncodingComment: '# encoding: utf-8' - -Style/FileName: - # File names listed in `AllCops:Include` are excluded by default. Add extra - # excludes here. - Exclude: [] - # When `true`, requires that each source file should define a class or module - # with a name which matches the file name (converted to ... case). - # It further expects it to be nested inside modules which match the names - # of subdirectories in its path. - ExpectMatchingDefinition: false - # If non-`nil`, expect all source file names to match the following regex. - # Only the file name itself is matched, not the entire file path. - # Use anchors as necessary if you want to match the entire name rather than - # just a part of it. - Regex: ~ - # With `IgnoreExecutableScripts` set to `true`, this cop does not - # report offending filenames for executable scripts (i.e. source - # files with a shebang in the first line). - IgnoreExecutableScripts: true - AllowedAcronyms: - - CLI - - DSL - - ACL - - API - - ASCII - - CPU - - CSS - - DNS - - EOF - - GUID - - HTML - - HTTP - - HTTPS - - ID - - IP - - JSON - - LHS - - QPS - - RAM - - RHS - - RPC - - SLA - - SMTP - - SQL - - SSH - - TCP - - TLS - - TTL - - UDP - - UI - - UID - - UUID - - URI - - URL - - UTF8 - - VM - - XML - - XMPP - - XSRF - - XSS - # Checks use of for or each in multiline loops. Style/For: EnforcedStyle: each SupportedStyles: - - for - each + - for # Enforce the method used for string formatting. Style/FormatString: EnforcedStyle: format SupportedStyles: @@ -855,10 +1051,11 @@ # Prefer tokens which contain a sprintf like type annotation like # `%<name>s`, `%<age>d`, `%<score>f` - annotated # Prefer simple looking "template" style tokens like `%{name}`, `%{age}` - template + - unannotated Style/FrozenStringLiteralComment: EnforcedStyle: when_needed SupportedStyles: # `when_needed` will add the frozen string literal comment to files @@ -896,15 +1093,11 @@ # Force hashes that have a symbol value to use hash rockets UseHashRocketsWithSymbolValues: false # Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style PreferHashRocketsForNonAlnumEndingSymbols: false -Style/IfUnlessModifier: - MaxLineLength: 80 - Style/InverseMethods: - Enabled: true # `InverseMethods` are methods that can be inverted by a not (`not` or `!`) # The relationship of inverse methods only needs to be defined in one direction. # Keys and values both need to be defined as symbols. InverseMethods: :any?: :none? @@ -938,22 +1131,29 @@ Style/MethodCallWithArgsParentheses: IgnoreMacros: true IgnoredMethods: [] +Style/MethodCallWithoutArgsParentheses: + IgnoredMethods: [] + Style/MethodDefParentheses: EnforcedStyle: require_parentheses SupportedStyles: - require_parentheses - require_no_parentheses - require_no_parentheses_except_multiline -Style/MethodName: - EnforcedStyle: snake_case +Style/MissingElse: + EnforcedStyle: both SupportedStyles: - - snake_case - - camelCase + # if - warn when an if expression is missing an else branch + # case - warn when a case expression is missing an else branch + # both - warn when an if or case expression is missing an else branch + - if + - case + - both # Checks the grouping of mixins (`include`, `extend`, `prepend`) in `class` and # `module` bodies. Style/MixinGrouping: EnforcedStyle: separated @@ -983,10 +1183,30 @@ # postfix: only use `unless` for negated `if` statements positioned after the body of the statement - both - prefix - postfix +Style/NestedParenthesizedCalls: + Whitelist: + - be + - be_a + - be_an + - be_between + - be_falsey + - be_kind_of + - be_instance_of + - be_truthy + - be_within + - eq + - eql + - end_with + - include + - match + - raise_error + - respond_to + - start_with + Style/Next: # With `always` all conditions at the end of an iteration needs to be # replaced by next - with `skip_modifier_ifs` the modifier if like this one # are ignored: [1, 2].each { |a| return 'yes' if a == 1 } EnforcedStyle: skip_modifier_ifs @@ -1055,30 +1275,10 @@ EnforcedStyle: lower_case_q SupportedStyles: - lower_case_q # Use `%q` when possible, `%Q` when necessary - upper_case_q # Always use `%Q` -Style/PredicateName: - # Predicate name prefixes. - NamePrefix: - - is_ - - has_ - - have_ - # Predicate name prefixes that should be removed. - NamePrefixBlacklist: - - is_ - - has_ - - have_ - # Predicate names which, despite having a blacklisted prefix, or no `?`, - # should still be accepted - NameWhitelist: - - is_a? - # Exclude Rspec specs because there is a strong convention to write spec - # helpers in the form of `have_something` or `be_something`. - Exclude: - - 'spec/**/*' - Style/PreferredHashMethods: EnforcedStyle: short SupportedStyles: - short - verbose @@ -1105,14 +1305,33 @@ - mixed # If `false`, the cop will always recommend using `%r` if one or more slashes # are found in the regexp string. AllowInnerSlashes: false +Style/RescueStandardError: + EnforcedStyle: explicit + # implicit: Do not include the error class, `rescue` + # explicit: Require an error class `rescue StandardError` + SupportedStyles: + - implicit + - explicit + +Style/ReturnNil: + EnforcedStyle: return + SupportedStyles: + - return + - return_nil + Style/SafeNavigation: # Safe navigation may cause a statement to start returning `nil` in addition # to whatever it used to return. ConvertCodeThatCanStartToReturnNil: false + Whitelist: + - present? + - blank? + - presence + - try Style/Semicolon: # Allow `;` to separate several expressions on the same line. AllowAsExpressionSeparator: false @@ -1203,21 +1422,32 @@ SupportedStylesForMultiline: - comma - consistent_comma - no_comma -Style/TrailingCommaInLiteral: - # If `comma`, the cop requires a comma after the last item in an array or - # hash, but only when each item is on its own line. +Style/TrailingCommaInArrayLiteral: + # If `comma`, the cop requires a comma after the last item in an array, + # but only when each item is on its own line. # If `consistent_comma`, the cop requires a comma after the last item of all - # non-empty array and hash literals. + # non-empty array literals. EnforcedStyleForMultiline: no_comma SupportedStylesForMultiline: - comma - consistent_comma - no_comma +Style/TrailingCommaInHashLiteral: + # If `comma`, the cop requires a comma after the last item in a hash, + # but only when each item is on its own line. + # If `consistent_comma`, the cop requires a comma after the last item of all + # non-empty hash literals. + EnforcedStyleForMultiline: no_comma + SupportedStylesForMultiline: + - comma + - consistent_comma + - no_comma + # `TrivialAccessors` requires exact name matches and doesn't allow # predicated methods by default. Style/TrivialAccessors: # When set to `false` the cop will suggest the use of accessor methods # in situations like: @@ -1256,26 +1486,10 @@ - to_regexp - to_str - to_s - to_sym -Style/VariableName: - EnforcedStyle: snake_case - SupportedStyles: - - snake_case - - camelCase - -Style/VariableNumber: - EnforcedStyle: normalcase - SupportedStyles: - - snake_case - - normalcase - - non_integer - -Style/WhileUntilModifier: - MaxLineLength: 80 - # `WordArray` enforces how array literals of word-like strings should be expressed. Style/WordArray: EnforcedStyle: percent SupportedStyles: # percent style: %w(word1 word2) @@ -1287,10 +1501,18 @@ # whose element count is greater than or equal to `MinSize`. MinSize: 0 # The regular expression `WordRegex` decides what is considered a word. WordRegex: !ruby/regexp '/\A[\p{Word}\n\t]+\z/' +Style/YodaCondition: + EnforcedStyle: all_comparison_operators + SupportedStyles: + # check all comparison operators + - all_comparison_operators + # check only equality operators: `!=` and `==` + - equality_operators_only + #################### Metrics ############################### Metrics/AbcSize: # The ABC size is a calculated magnitude, so this number can be an Integer or # a Float. @@ -1349,74 +1571,51 @@ # Allow safe assignment in conditions. Lint/AssignmentInCondition: AllowSafeAssignment: true -# checks whether the end keywords are aligned properly for `do` `end` blocks. -Lint/BlockAlignment: - # The value `start_of_block` means that the `end` should be aligned with line - # where the `do` keyword appears. - # The value `start_of_line` means it should be aligned with the whole - # expression's starting line. - # The value `either` means both are allowed. - EnforcedStyleAlignWith: either - SupportedStylesAlignWith: - - either - - start_of_block - - start_of_line - -Lint/DefEndAlignment: - # The value `def` means that `end` should be aligned with the def keyword. - # The value `start_of_line` means that `end` should be aligned with method - # calls like `private`, `public`, etc, if present in front of the `def` - # keyword on the same line. - EnforcedStyleAlignWith: start_of_line - SupportedStylesAlignWith: - - start_of_line - - def - AutoCorrect: false - -# Align ends correctly. -Lint/EndAlignment: - # The value `keyword` means that `end` should be aligned with the matching - # keyword (`if`, `while`, etc.). - # The value `variable` means that in assignments, `end` should be aligned - # with the start of the variable on the left hand side of `=`. In all other - # situations, `end` should still be aligned with the keyword. - # The value `start_of_line` means that `end` should be aligned with the start - # of the line which the matching keyword appears on. - EnforcedStyleAlignWith: keyword - SupportedStylesAlignWith: - - keyword - - variable - - start_of_line - AutoCorrect: false - Lint/InheritException: # The default base class in favour of `Exception`. EnforcedStyle: runtime_error SupportedStyles: - runtime_error - standard_error +Lint/MissingCopEnableDirective: + # Maximum number of consecutive lines the cop can be disabled for. + # 0 allows only single-line disables + # 1 would mean the maximum allowed is the following: + # # rubocop:disable SomeCop + # a = 1 + # # rubocop:enable SomeCop + # .inf for any size + MaximumRangeSize: .inf + Lint/SafeNavigationChain: Whitelist: - present? - blank? - presence - try +# Checks for shadowed arguments +Lint/ShadowedArgument: + IgnoreImplicitReferences: false + # Checks for unused block arguments Lint/UnusedBlockArgument: IgnoreEmptyBlocks: true AllowUnusedKeywordArguments: false # Checks for unused method arguments. Lint/UnusedMethodArgument: AllowUnusedKeywordArguments: false IgnoreEmptyMethods: true +Lint/Void: + CheckForMethodsWithNoSideEffects: false + #################### Performance ########################### Performance/DoubleStartEndWith: # Used to check for `starts_with?` and `ends_with?`. # These methods are defined by `ActiveSupport`. @@ -1434,10 +1633,14 @@ - action - filter Include: - app/controllers/**/*.rb +Rails/CreateTableWithTimestamps: + Include: + - db/migrate/*.rb + Rails/Date: # The value `strict` disallows usage of `Date.today`, `Date.current`, # `Date#to_time` etc. # The value `flexible` allows usage of `Date.current`, `Date.yesterday`, etc # (but not `Date.today`) which are overridden by ActiveSupport to handle current @@ -1445,10 +1648,16 @@ EnforcedStyle: flexible SupportedStyles: - strict - flexible +Rails/Delegate: + # When set to true, using the target object as a prefix of the + # method name without using the `delegate` method will be a + # violation. When set to false, this case is legal. + EnforceForPrefixed: true + Rails/DynamicFindBy: Whitelist: - find_by_sql Rails/EnumUniqueness: @@ -1473,10 +1682,28 @@ Rails/HasAndBelongsToMany: Include: - app/models/**/*.rb +Rails/HasManyOrHasOneDependent: + Include: + - app/models/**/*.rb + +Rails/HttpStatus: + EnforcedStyle: symbolic + SupportedStyles: + - numeric + - symbolic + +Rails/InverseOf: + Include: + - app/models/**/*.rb + +Rails/LexicallyScopedActionFilter: + Include: + - app/controllers/**/*.rb + Rails/NotNullColumn: Include: - db/migrate/*.rb Rails/Output: @@ -1500,11 +1727,11 @@ Include: - db/migrate/*.rb Rails/SafeNavigation: # This will convert usages of `try` to use safe navigation as well as `try!`. - # `try` and `try!` work slighly differently. `try!` and safe navigation will + # `try` and `try!` work slightly differently. `try!` and safe navigation will # both raise a `NoMethodError` if the receiver of the method call does not # implement the intended method. `try` will not raise an exception for this. ConvertTry: false Rails/ScopeArgs: @@ -1524,10 +1751,16 @@ SupportedStyles: - conservative - aggressive AutoCorrect: false +Rails/UnknownEnv: + Environments: + - development + - test + - production + Rails/SkipsModelValidations: Blacklist: - decrement! - decrement_counter - increment! @@ -1543,6 +1776,9 @@ Rails/Validation: Include: - app/models/**/*.rb Bundler/OrderedGems: + TreatCommentsAsGroupSeparators: true + +Gemspec/OrderedDependencies: TreatCommentsAsGroupSeparators: true