Rubocop: Change existing cop message templates to use annotated template strings

Created on 16 Nov 2017  路  4Comments  路  Source: rubocop-hq/rubocop

Most cops currently use an unannotated template string for their message template(s):

Bad example:

MSG = 'Place the condition on the same line as `%s`.'.freeze

...

format(MSG, keyword)

These should actually use annotated strings, to provide context, and reduce connascence of the format arguments.

Good example:

MSG = 'Place the condition on the same line as `%<keyword>s`.'.freeze

...

format(MSG, keyword: keyword)

Progress:

  • [x] Bundler/DuplicatedGem
  • [x] Bundler/InsecureProtocolSource
  • [x] Bundler/OrderedGems
  • [x] Gemspec/OrderedDependencies
  • [x] Layout/AccessModifierIndentation
  • [x] Layout/AlignParameters
  • [x] Layout/BlockEndNewline
  • [x] Layout/CaseIndentation
  • [x] Layout/CommentIndentation
  • [x] Layout/ElseAlignment
  • [x] Layout/EmptyLinesAroundAccessModifier
  • [x] Layout/EmptyLinesAroundExceptionHandlingKeywords
  • [x] Layout/ExtraSpacing
  • [x] Layout/FirstParameterIndentation
  • [x] Layout/IndentArray
  • [x] Layout/IndentHash
  • [x] Layout/IndentHeredoc
  • [x] Layout/IndentationWidth
  • [x] Layout/RescueEnsureAlignment
  • [x] Layout/SpaceAroundEqualsInParameterDefault
  • [x] Layout/SpaceAroundKeyword
  • [ ] Layout/SpaceInsideArrayPercentLiteral
  • [ ] Layout/SpaceInsideHashLiteralBraces
  • [ ] Layout/SpaceInsidePercentLiteralDelimiters
  • [ ] Layout/TrailingBlankLines
  • [ ] Lint/AmbiguousBlockAssociation
  • [ ] Lint/BlockAlignment
  • [ ] Lint/BooleanSymbol
  • [ ] Lint/CircularArgumentReference
  • [ ] Lint/ConditionPosition
  • [ ] Lint/Debugger
  • [ ] Lint/DefEndAlignment
  • [ ] Lint/DeprecatedClassMethods
  • [ ] Lint/DuplicateMethods
  • [ ] Lint/FormatParameterMismatch
  • [ ] Lint/ImplicitStringConcatenation
  • [ ] Lint/IneffectiveAccessModifier
  • [ ] Lint/InheritException
  • [ ] Lint/LiteralAsCondition
  • [ ] Lint/MissingCopEnableDirective
  • [ ] Lint/PercentSymbolArray
  • [ ] Lint/RandOne
  • [ ] Lint/RescueType
  • [ ] Lint/ReturnInVoidContext
  • [ ] Lint/ScriptPermission
  • [ ] Lint/ShadowedArgument
  • [ ] Lint/ShadowingOuterLocalVariable
  • [ ] Lint/UnifiedInteger
  • [ ] Lint/UnneededSplatExpansion
  • [ ] Lint/UriEscapeUnescape
  • [ ] Lint/UselessAccessModifier
  • [ ] Lint/UselessAssignment
  • [ ] Lint/UselessSetterCall
  • [ ] Lint/Void
  • [x] Metrics/AbcSize
  • [x] Metrics/ClassLength
  • [x] Metrics/CyclomaticComplexity
  • [x] Metrics/LineLength
  • [x] Metrics/ModuleLength
  • [x] Metrics/ParameterLists
  • [x] Metrics/PerceivedComplexity
  • [x] Naming/BinaryOperatorParameterName
  • [x] Naming/FileName
  • [x] Naming/HeredocDelimiterCase
  • [x] Performance/CaseWhenSplat
  • [x] Performance/Casecmp
  • [x] Performance/CompareWithBlock
  • [x] Performance/Count
  • [x] Performance/Detect
  • [x] Performance/FlatMap
  • [x] Performance/HashEachMethods
  • [x] Performance/LstripRstrip
  • [x] Performance/RedundantBlockCall
  • [x] Performance/RedundantMerge
  • [x] Performance/RedundantSortBy
  • [x] Performance/RegexpMatch
  • [x] Performance/StringReplacement
  • [x] Performance/UriDefaultParser
  • [ ] Rails/ActionFilter
  • [ ] Rails/ActiveSupportAliases
  • [ ] Rails/Blank
  • [ ] Rails/Date
  • [ ] Rails/DynamicFindBy
  • [ ] Rails/EnumUniqueness
  • [ ] Rails/EnvironmentComparison
  • [ ] Rails/FindBy
  • [ ] Rails/HttpPositionalArguments
  • [ ] Rails/PluralizationGrammar
  • [ ] Rails/Present
  • [ ] Rails/ReadWriteAttribute
  • [ ] Rails/RelativeDateConstant
  • [ ] Rails/RequestReferer
  • [ ] Rails/ReversibleMigration
  • [ ] Rails/SafeNavigation
  • [ ] Rails/SaveBang
  • [ ] Rails/SkipsModelValidations
  • [ ] Rails/TimeZone
  • [ ] Rails/UniqBeforePluck
  • [ ] Rails/Validation
  • [x] Security/JsonLoad
  • [x] Security/MarshalLoad
  • [x] Style/Alias
  • [x] Style/AndOr
  • [x] Style/Attr
  • [x] Style/AutoResourceCleanup
  • [x] Style/BarePercentLiterals
  • [x] Style/BracesAroundHashParameters
  • [x] Style/ClassCheck
  • [x] Style/ClassMethods
  • [x] Style/ClassVars
  • [x] Style/CollectionMethods
  • [x] Style/CommandLiteral
  • [x] Style/CommentAnnotation
  • [x] Style/CommentedKeyword
  • [x] Style/Copyright
  • [x] Style/Documentation
  • [x] Style/EachWithObject
  • [x] Style/EmptyLiteral
  • [x] Style/EvenOdd
  • [x] Style/FormatString
  • [x] Style/IdenticalConditionalBranches
  • [x] Style/IfUnlessModifier
  • [x] Style/IfUnlessModifierOfIfUnless
  • [x] Style/ImplicitRuntimeError
  • [x] Style/Lambda
  • [x] Style/MethodMissing
  • [x] Style/MissingElse
  • [x] Style/MixinGrouping
  • [x] Style/MultilineIfModifier
  • [x] Style/MultilineIfThen
  • [x] Style/NegatedIf
  • [x] Style/NegatedWhile
  • [x] Style/NestedParenthesizedCalls
  • [x] Style/NumericLiterals
  • [x] Style/NumericPredicate
  • [x] Style/OneLineConditional
  • [x] Style/PercentLiteralDelimiters
  • [x] Style/PreferredHashMethods
  • [x] Style/RaiseArgs
  • [x] Style/RedundantConditional
  • [x] Style/SelfAssignment
  • [x] Style/SingleLineBlockParams
  • [x] Style/SpecialGlobalVars
  • [x] Style/StringMethods
  • [x] Style/SymbolArray
  • [x] Style/SymbolProc
  • [x] Style/TernaryParentheses
  • [x] Style/TrailingCommaInArguments
  • [x] Style/TrailingCommaInLiteral
  • [x] Style/TrailingUnderscoreVariable
  • [x] Style/TrivialAccessors
  • [x] Style/UnneededPercentQ
  • [x] Style/VariableInterpolation
  • [x] Style/WhileUntilDo
  • [x] Style/WhileUntilModifier
  • [x] Style/YodaCondition
  • [x] Style/ZeroLengthPredicate
enhancement help wanted

All 4 comments

Can I take it?

@mokpro: Sure. Please try to do it in batches (try not to submit one huge PR), and update the checklist above as you go. 馃檪

@Drenmi Thank you. I've created first pull request #5070 with ~20 files changed.
Please review it.

Also, I don't have permissions to updated the above description.

Starting at the bottom of the checklist and doing a large batch ascending up.

Was this page helpful?
0 / 5 - 0 ratings