Skip to content

Instantly share code, notes, and snippets.

@MyklClason
Last active February 1, 2023 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MyklClason/625c53576d8d0d584c2d19ce772542bc to your computer and use it in GitHub Desktop.
Save MyklClason/625c53576d8d0d584c2d19ce772542bc to your computer and use it in GitHub Desktop.
Code Quality Config. Copy the files
# https://github.com/Shopify/erb-lint
linters:
DeprecatedClasses:
enabled: true
FinalNewline:
enabled: true
ErbSafety:
enabled: true
exclude:
- '**/node_modules/**'
Rubocop:
enabled: true
rubocop_config:
inherit_from:
- .rubocop.yml
Layout/InitialIndentation:
Enabled: false
Layout/TrailingBlankLines:
Enabled: false
Layout/TrailingWhitespace:
Enabled: false
Naming/FileName:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
Layout/LineLength:
Enabled: false
Lint/UselessAssignment:
Enabled: false
Style/StringLiterals:
Enabled: false
Style/Semicolon:
Enabled: false
Layout/AlignHash:
Enabled: false
RightTrim:
enabled: true
enforced_style: '-'
SpaceAroundErbTag:
enabled: true
NoJavascriptTagHelper:
enabled: true
correction_style: 'plain'
SelfClosingTag:
enabled: true
enforced_style: 'never'
AllowedScriptType:
enabled: true
# This should only include the bare minimium for a rails app.
# https://github.com/rubocop-hq/rubocop
inherit_from:
- .rubocop_base.yml # Include base first so it's overridden by todo
- .rubocop_overrides.yml
- .rubocop_todo_refactor.yml
- .rubocop_todo.yml
require:
- rubocop-rails
- rubocop-rspec
AllCops:
NewCops: enable
Exclude:
- 'bin/*'
- 'db/schema.rb'
- 'node_modules/*'
- 'node_modules/**/*'
# This is the base rubocop settings. This is the baseline COP settings for Rails apps
# Inital version from: https://gist.github.com/jhass/a5ae80d87f18e53e7b56
# Commonly used screens these days easily fit more than 80 characters.
Layout/LineLength:
Max: 120
Exclude:
- 'config/**/*'
- 'bin/**/*'
# Too short methods lead to extraction of single-use methods, which can make
# the code easier to read (by naming things), but can also clutter the class
Metrics/MethodLength:
Max: 25
# The guiding principle of classes is SRP, SRP can't be accurately measured by LoC
Metrics/ClassLength:
Max: 1500
# No space makes the method definition shorter and differentiates
# from a regular assignment.
Layout/SpaceAroundEqualsInParameterDefault:
EnforcedStyle: no_space
# Single quotes being faster is hardly measurable and only affects parse time.
# Enforcing double quotes reduces the times where you need to change them
# when introducing an interpolation. Use single quotes only if their semantics
# are needed.
Style/StringLiterals:
EnforcedStyle: double_quotes
# We do not need to support Ruby 1.9, so this is good to use.
Style/SymbolArray:
Enabled: true
Metrics/AbcSize:
Max: 30
Metrics/CyclomaticComplexity:
Max: 30
# Just have a preference for Compact
Style/ClassAndModuleChildren:
EnforcedStyle: compact
Exclude:
- 'app/channels/application_cable/channel.rb'
- 'app/channels/application_cable/connection.rb'
- 'config/application.rb'
- 'spec/helpers/**/*'
# Permit empty blocks for required/optional inputs
Lint/EmptyBlock:
Exclude:
- 'app/mutations/**/*'
# This is fine.
Lint/MissingSuper:
Exclude:
- 'app/components/**/*'
Metrics/BlockLength:
AllowedMethods:
- configure
- draw # Routes
# Enabled as desired. Comment out/delete to check for documentation of section
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'app/**/*'
- 'config/**/*'
- 'db/**/*'
Style/MixinUsage:
Exclude:
- 'bin/setup'
- 'bin/update'
Layout/MultilineOperationIndentation:
EnforcedStyle: indented
Lint/SuppressedException:
AllowComments: true
Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: comma
Metrics/ParameterLists:
Max: 7
Style/ConditionalAssignment:
EnforcedStyle: assign_inside_condition
# @todo: Performance test this to see if it's worth including
Style/FrozenStringLiteralComment:
EnforcedStyle: never
# Conflicts with a Rails cop when within models
Style/RedundantSelf:
Exclude:
- 'app/models/**/*'
Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: consistent_comma
RSpec/ExampleLength:
Exclude:
- 'spec/requests/**/*'
- 'spec/views/**/*'
RSpec/MultipleExpectations:
Exclude:
- 'spec/requests/**/*'
- 'spec/views/**/*'
RSpec/ContextWording:
Prefixes:
- when
- with
- without
- if
- unless
- for
# This should be used to override base settings for this specific repo. Also includes stuff that may conflict with the base settings.
# Weird issue where these don't work right.
Style/ClassAndModuleChildren:
Exclude:
- 'spec/helpers/**/*'
- 'app/channels/application_cable/channel.rb'
- 'app/channels/application_cable/connection.rb'
- 'config/application.rb'
Style/GlobalVars:
AllowedVariables: ["$factory_bot_usage_count"]
# This file is automatically generated by: `rubocop --auto-gen-config`
# If the other two files are setup correctly then
# running `rubocop --autocorrect` then `rubocop --auto-gen-config` on a new rails repo should have no offenses detected.
# This file is used to exclude specific files from specific cops, with the intent they will be refactored later.
# This acts as a more explictly defined todo list than the auto-generated rubocop todo list.
# https://github.com/sds/slim-lint
# Default application configuration that all configurations inherit from.
#
# This is an opinionated list of which hooks are valuable to run and what their
# out of the box settings should be.
# Whether to ignore frontmatter at the beginning of Slim documents for
# frameworks such as Jekyll/Middleman
skip_frontmatter: false
linters:
CommentControlStatement:
enabled: true
ConsecutiveControlStatements:
enabled: true
max_consecutive: 2
# I find no space to be visually useful, so disabled
ControlStatementSpacing:
enabled: false
EmptyControlStatement:
enabled: true
EmptyLines:
enabled: true
# We should keep files short, use partials if they get long
FileLength:
enabled: true
max: 300
# Handled by rubocop when enabled
LineLength:
enabled: false
RedundantDiv:
enabled: true
RuboCop:
enabled: true
# Disable noisy/and wontfix cops
ignored_cops:
- Layout/AlignArguments
- Layout/AlignArray
- Layout/AlignHash
- Layout/AlignParameters
- Layout/EmptyLineAfterGuardClause
- Layout/FirstParameterIndentation
- Layout/IndentArray
- Layout/IndentationConsistency
- Layout/IndentationWidth
- Layout/InitialIndentation
- Layout/MultilineArrayBraceLayout
- Layout/MultilineAssignmentLayout
- Layout/MultilineHashBraceLayout
- Layout/MultilineMethodCallBraceLayout
- Layout/MultilineMethodCallIndentation
- Layout/MultilineMethodDefinitionBraceLayout
- Layout/MultilineOperationIndentation
- Layout/TrailingBlankLines
- Layout/TrailingWhitespace
- Lint/BlockAlignment
- Lint/EndAlignment
- Lint/Void
- Metrics/BlockLength
- Metrics/BlockNesting
- Metrics/LineLength
- Naming/FileName
- Style/FrozenStringLiteralComment
- Style/IfUnlessModifier
- Style/Next
- Style/WhileUntilModifier
# wontfix, these are too nitpicky to bother with without autocorrect
- Style/StringLiterals
- Style/ConditionalAssignment # Not always practical
# Temp ignored
- Lint/LiteralAsCondition
Tab:
enabled: true
TagCase:
enabled: true
TrailingBlankLines:
enabled: true
TrailingWhitespace:
enabled: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment