Permalink
Browse files

Import Rails cops from RuboCop Core

These are committing parts that were not picked up by `git cherry-pick`
from RuboCop Core.
  • Loading branch information...
koic committed Oct 26, 2018
1 parent 1a47ba4 commit 12e0d027e8dcb5b590a37317ce1d33a5f3ae4925
Showing with 754 additions and 0 deletions.
  1. +2 −0 .rspec
  2. +93 −0 .rubocop.yml
  3. +69 −0 .rubocop_todo.yml
  4. +205 −0 config/default.yml
  5. +85 −0 config/disabled.yml
  6. +209 −0 config/enabled.yml
  7. +1 −0 lib/rubocop-rails.rb
  8. +55 −0 lib/rubocop/cop/rails_cops.rb
  9. +1 −0 rubocop-rails.gemspec
  10. +34 −0 spec/spec_helper.rb
2 .rspec
@@ -0,0 +1,2 @@
--color
--require spec_helper
@@ -0,0 +1,93 @@
# This is the configuration used to check the rubocop source code.
inherit_from: .rubocop_todo.yml
require:
- rubocop/cop/internal_affairs
- rubocop-rspec
AllCops:
Exclude:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
- 'tmp/**/*'
TargetRubyVersion: 2.2
Naming/PredicateName:
# Method define macros for dynamically generated method.
MethodDefinitionMacros:
- define_method
- define_singleton_method
- def_node_matcher
- def_node_search
Style/FrozenStringLiteralComment:
EnforcedStyle: always
Style/FormatStringToken:
# Because we parse a lot of source codes from strings. Percent arrays
# look like unannotated format string tokens to this cop.
Exclude:
- spec/**/*
Style/IpAddresses:
# The test for this cop includes strings that would cause offenses
Exclude:
- spec/rubocop/cop/style/ip_addresses_spec.rb
Layout/EndOfLine:
EnforcedStyle: lf
Layout/ClassStructure:
Enabled: true
Categories:
module_inclusion:
- include
- prepend
- extend
ExpectedOrder:
- module_inclusion
- constants
- public_class_methods
- initializer
- instance_methods
- protected_methods
- private_methods
Layout/IndentHeredoc:
EnforcedStyle: powerpack
# Trailing white space is meaningful in code examples
Layout/TrailingWhitespace:
AllowInHeredoc: true
Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/**/*.rb'
Lint/InterpolationCheck:
Exclude:
- 'spec/**/*.rb'
Lint/UselessAccessModifier:
MethodCreatingMethods:
- 'def_matcher'
- 'def_node_matcher'
Lint/BooleanSymbol:
Enabled: false
Metrics/BlockLength:
Exclude:
- 'Rakefile'
- '**/*.rake'
- 'spec/**/*.rb'
Metrics/ModuleLength:
Exclude:
- 'spec/**/*.rb'
RSpec/PredicateMatcher:
EnforcedStyle: explicit
RSpec/NestedGroups:
Max: 7
@@ -0,0 +1,69 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-07-14 05:02:14 +0900 using RuboCop version 0.58.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 1
# Cop supports --auto-correct.
Lint/UnneededCopDisableDirective:
Exclude:
- 'rubocop-rails.gemspec'
# Offense count: 7
Metrics/AbcSize:
Max: 18
# Offense count: 3
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 146
# Offense count: 7
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 14
# Offense count: 61
# Configuration parameters: Prefixes.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'spec/rubocop/cop/rails/blank_spec.rb'
- 'spec/rubocop/cop/rails/bulk_change_table_spec.rb'
- 'spec/rubocop/cop/rails/delegate_spec.rb'
- 'spec/rubocop/cop/rails/exit_spec.rb'
- 'spec/rubocop/cop/rails/file_path_spec.rb'
- 'spec/rubocop/cop/rails/has_many_or_has_one_dependent_spec.rb'
- 'spec/rubocop/cop/rails/inverse_of_spec.rb'
- 'spec/rubocop/cop/rails/present_spec.rb'
- 'spec/rubocop/cop/rails/read_write_attribute_spec.rb'
- 'spec/rubocop/cop/rails/redundant_receiver_in_with_options_spec.rb'
- 'spec/rubocop/cop/rails/reversible_migration_spec.rb'
- 'spec/rubocop/cop/rails/safe_navigation_spec.rb'
# Offense count: 174
# Configuration parameters: Max.
RSpec/ExampleLength:
Enabled: false
# Offense count: 38
# Configuration parameters: AggregateFailuresByDefault.
RSpec/MultipleExpectations:
Max: 5
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: when_needed, always, never
Style/FrozenStringLiteralComment:
Exclude:
- 'spec/spec_helper.rb'
# Offense count: 1
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Exclude:
- 'spec/spec_helper.rb'
@@ -0,0 +1,205 @@
# This is the default configuration file. Enabling and disabling is configured
# in separate files. This file adds all other parameters apart from Enabled.
inherit_from:
- enabled.yml
- disabled.yml
# Common configuration.
AllCops:
# 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: ~
Rails/ActionFilter:
EnforcedStyle: action
SupportedStyles:
- action
- filter
Include:
- app/controllers/**/*.rb
Rails/AssertNot:
Include:
- '**/test/**/*'
Rails/Blank:
# Convert usages of `nil? || empty?` to `blank?`
NilOrEmpty: true
# Convert usages of `!present?` to `blank?`
NotPresent: true
# Convert usages of `unless present?` to `if blank?`
UnlessPresent: true
Rails/BulkChangeTable:
Database: null
SupportedDatabases:
- mysql
- postgresql
Include:
- db/migrate/*.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
# time zone.
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:
Include:
- app/models/**/*.rb
Rails/Exit:
Include:
- app/**/*.rb
- config/**/*.rb
- lib/**/*.rb
Exclude:
- lib/**/*.rake
Rails/FilePath:
EnforcedStyle: arguments
SupportedStyles:
- slashes
- arguments
Rails/FindBy:
Include:
- app/models/**/*.rb
Rails/FindEach:
Include:
- app/models/**/*.rb
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:
Include:
- app/**/*.rb
- config/**/*.rb
- db/**/*.rb
- lib/**/*.rb
Rails/Present:
# Convert usages of `!nil? && !empty?` to `present?`
NotNilAndNotEmpty: true
# Convert usages of `!blank?` to `present?`
NotBlank: true
# Convert usages of `unless blank?` to `if present?`
UnlessBlank: true
Rails/ReadWriteAttribute:
Include:
- app/models/**/*.rb
Rails/RefuteMethods:
Include:
- '**/test/**/*'
Rails/RequestReferer:
EnforcedStyle: referer
SupportedStyles:
- referer
- referrer
Rails/ReversibleMigration:
Include:
- db/migrate/*.rb
Rails/SafeNavigation:
# This will convert usages of `try` to use safe navigation as well as `try!`.
# `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:
Include:
- app/models/**/*.rb
Rails/TimeZone:
# The value `strict` means that `Time` should be used with `zone`.
# The value `flexible` allows usage of `in_time_zone` instead of `zone`.
EnforcedStyle: flexible
SupportedStyles:
- strict
- flexible
Rails/UniqBeforePluck:
EnforcedStyle: conservative
SupportedStyles:
- conservative
- aggressive
AutoCorrect: false
Rails/UnknownEnv:
Environments:
- development
- test
- production
Rails/SkipsModelValidations:
Blacklist:
- decrement!
- decrement_counter
- increment!
- increment_counter
- toggle!
- touch
- update_all
- update_attribute
- update_column
- update_columns
- update_counters
Rails/Validation:
Include:
- app/models/**/*.rb
Oops, something went wrong.

0 comments on commit 12e0d02

Please sign in to comment.