0.0
No commit activity in last 3 years
No release in over 3 years
Adds a task to run rubocop, reek, rails_best_practices and scss lint into your rails project
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 4.7.2
~> 0.51.0
~> 0.55.0
 Project Readme

This gem adds the most common code analysis tools for a Rails project

Used tools

  1. Rubocop
  2. Reek
  3. Rails Best Practices
  4. SCSS-lint

Installation

gem install code_analysis

How to use the task

If you wanna run all the code analysis tools

rake code_analysis

If you wanna disable any code analysis tool

You can pass some disability rules as params to the rake task using the '/' character

Example to disable reek and rubocop: rake code_analysis[disable_rubocop/disable_reek]

Example to run all tools: rake code_analysis

The options to disable tools are:

  • disable_rubocop
  • disable_reek
  • disable_rails_best_practices
  • disable_scss_lint

What is required to use?


Rubocop

  1. Add a .rubocop.yml file in the base path of your rails application to customize your cops.

Recommended one:

Documentation:
  Enabled: false
Style/FrozenStringLiteralComment:
  Enabled: false

Reek

  1. Add a .reek file in the base path of your rails application to customize reek. Default one.

Rails best Practices

No needs :)


SCSS lint

  1. Add a .scss_lint.yml file in the base path of your rails application to customize your linters.

Recommended one:

scss_files: "app/assets/stylesheets/**/*.scss"
exclude: []
plugin_directories: ['.scss-linters']

plugin_gems: []

severity: warning

linters:
  BangFormat:
    enabled: true
    space_before_bang: true
    space_after_bang: false

  BemDepth:
    enabled: false
    max_elements: 1

  BorderZero:
    enabled: true
    convention: zero

  ChainedClasses:
    enabled: false

  ColorKeyword:
    enabled: true

  ColorVariable:
    enabled: true

  Comment:
    enabled: true
    style: silent

  DebugStatement:
    enabled: true

  DeclarationOrder:
    enabled: true

  DisableLinterReason:
    enabled: false

  DuplicateProperty:
    enabled: true

  ElsePlacement:
    enabled: true
    style: same_line

  EmptyLineBetweenBlocks:
    enabled: true
    ignore_single_line_blocks: true

  EmptyRule:
    enabled: true

  ExtendDirective:
    enabled: false

  FinalNewline:
    enabled: true
    present: true

  HexLength:
    enabled: true
    style: short

  HexNotation:
    enabled: true
    style: lowercase

  HexValidation:
    enabled: true

  IdSelector:
    enabled: true

  ImportantRule:
    enabled: true

  ImportPath:
    enabled: true
    leading_underscore: false
    filename_extension: false

  Indentation:
    enabled: true
    allow_non_nested_indentation: false
    character: space
    width: 2

  LeadingZero:
    enabled: true
    style: exclude_zero

  MergeableSelector:
    enabled: true
    force_nesting: true

  NameFormat:
    enabled: true
    allow_leading_underscore: true
    convention: hyphenated_lowercase

  NestingDepth:
    enabled: true
    max_depth: 3
    ignore_parent_selectors: false

  PlaceholderInExtend:
    enabled: true

  PrivateNamingConvention:
    enabled: false
    prefix: _

  PropertyCount:
    enabled: false
    include_nested: false
    max_properties: 10

  PropertySortOrder:
    enabled: true
    ignore_unspecified: false
    min_properties: 2
    separate_groups: false

  PropertySpelling:
    enabled: true
    extra_properties: []
    disabled_properties: []

  PropertyUnits:
    enabled: true
    global: [
      'ch', 'em', 'ex', 'rem',
      'cm', 'in', 'mm', 'pc', 'pt', 'px', 'q',
      'vh', 'vw', 'vmin', 'vmax',
      'deg', 'grad', 'rad', 'turn',
      'ms', 's',
      'Hz', 'kHz',
      'dpi', 'dpcm', 'dppx',
      '%']
    properties: {}

  PseudoElement:
    enabled: true

  QualifyingElement:
    enabled: true
    allow_element_with_attribute: false
    allow_element_with_class: false
    allow_element_with_id: false

  SelectorDepth:
    enabled: true
    max_depth: 3

  SelectorFormat:
    enabled: true
    convention: hyphenated_lowercase

  Shorthand:
    enabled: true
    allowed_shorthands: [1, 2, 3, 4]

  SingleLinePerProperty:
    enabled: true
    allow_single_line_rule_sets: true

  SingleLinePerSelector:
    enabled: true

  SpaceAfterComma:
    enabled: true
    style: one_space

  SpaceAfterComment:
    enabled: false
    style: one_space
    allow_empty_comments: true

  SpaceAfterPropertyColon:
    enabled: true
    style: one_space

  SpaceAfterPropertyName:
    enabled: true

  SpaceAfterVariableColon:
    enabled: false
    style: one_space

  SpaceAfterVariableName:
    enabled: true

  SpaceAroundOperator:
    enabled: true
    style: one_space

  SpaceBeforeBrace:
    enabled: true
    style: space
    allow_single_line_padding: false

  SpaceBetweenParens:
    enabled: true
    spaces: 0

  StringQuotes:
    enabled: true
    style: single_quotes

  TrailingSemicolon:
    enabled: true

  TrailingWhitespace:
    enabled: true

  TrailingZero:
    enabled: false

  TransitionAll:
    enabled: false

  UnnecessaryMantissa:
    enabled: true

  UnnecessaryParentReference:
    enabled: true

  UrlFormat:
    enabled: true

  UrlQuotes:
    enabled: true

  VariableForProperty:
    enabled: false
    properties: []

  VendorPrefix:
    enabled: true
    identifier_list: base
    additional_identifiers: []
    excluded_identifiers: []

  ZeroUnit:
    enabled: true

  Compass::*:
    enabled: false