diff --git a/.rubocop.yml b/.rubocop.yml index 802a6e6..9c49771 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 0000000..2dbdfa8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# rubocop-github + +## Unreleased + +- 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 41c4de2..e0932d2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 b5fb2ad..8796a67 100644 --- a/README.md +++ b/README.md @@ -4,25 +4,37 @@ 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.yml - - config/rails.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 If you are using a rubocop version < 1.0.0, you can use rubocop-github version @@ -37,4 +49,4 @@ bundle exec rake test ## The Cops -All cops are located under [`lib/rubocop/cop/github`](lib/rubocop/cop/github) and [`lib/rubocop/cop/github/accessibility`](lib/rubocop/cop/github/accessibility), 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 4418ad9..1e55a3b 100644 --- a/STYLEGUIDE.md +++ b/STYLEGUIDE.md @@ -418,9 +418,8 @@ hsh = { [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)] -``` ruby - So instead of this: + ``` ruby def remove_member(user, skip_membership_check=false) # ... @@ -430,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) # ... diff --git a/config/default.yml b/config/default.yml index 67af72a..52a0655 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 0000000..00b5ea0 --- /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 ab16d61..e414a00 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 0000000..ef3d9a4 --- /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/guides/image-has-alt.md b/guides/image-has-alt.md deleted file mode 100644 index a761dba..0000000 --- a/guides/image-has-alt.md +++ /dev/null @@ -1,29 +0,0 @@ -# GitHub/Accessibility/ImageHasAlt - -## Rule Details - -Images should have an alt prop with meaningful text or an empty string for decorative images. - -## Resources - -- [W3C WAI Images Tutorial](https://www.w3.org/WAI/tutorials/images/) -- [Primer: Alternative text for images](https://primer.style/design/accessibility/alternative-text-for-images) - -## Examples -### **Incorrect** code for this rule 👎 - -```erb -<%= image_tag "spinners/octocat-spinner-16px.gif", size: "12x12" %> -``` - -### **Correct** code for this rule 👍 - -```erb - -<%= image_tag "spinners/octocat-spinner-16px.gif", size: "12x12", alt: "GitHub Logo spinner" %> -``` - -```erb - -<%= image_tag "spinners/octocat-spinner-16px.gif", size: "12x12", alt: "" %> -``` \ No newline at end of file diff --git a/guides/link-has-href.md b/guides/link-has-href.md deleted file mode 100644 index 8a574c9..0000000 --- a/guides/link-has-href.md +++ /dev/null @@ -1,29 +0,0 @@ -# GitHub/Accessibility/LinkHasHref - -## Rule Details - -Links should go somewhere, you probably want to use a `