Browse Source

Rubocop

get_specs_running
baarkerlounger 3 years ago
parent
commit
886cd667ee
  1. 98
      .rubocop.yml
  2. 21
      Gemfile
  3. 12
      Rakefile
  4. 4
      spec/rails_app/Rakefile
  5. 9
      spec/rails_app/script/rails

98
.rubocop.yml

@ -4,6 +4,24 @@ AllCops:
- '**/Rakefile' - '**/Rakefile'
UseCache: true UseCache: true
Layout/LineLength:
Description: Limit lines to 80 characters.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#80-character-limits
Enabled: true
Max: 100
AllowURI: true
URISchemes:
- http
- https
Layout/DotPosition:
Description: Checks the position of the dot in multi-line method calls.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
Enabled: true
EnforcedStyle: trailing
SupportedStyles:
- leading
- trailing
Lint/AssignmentInCondition: Lint/AssignmentInCondition:
Description: Don't use assignment in conditions. Description: Don't use assignment in conditions.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
@ -12,11 +30,11 @@ Lint/AssignmentInCondition:
Lint/EachWithObjectArgument: Lint/EachWithObjectArgument:
Description: Check for immutable argument given to each_with_object. Description: Check for immutable argument given to each_with_object.
Enabled: true Enabled: true
Lint/HandleExceptions: Lint/SuppressedException:
Description: Don't suppress exception. Description: Don't suppress exception.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
Enabled: true Enabled: true
Lint/LiteralInCondition: Lint/LiteralAsCondition:
Description: Checks of literals used in conditions. Description: Checks of literals used in conditions.
Enabled: true Enabled: true
Lint/LiteralInInterpolation: Lint/LiteralInInterpolation:
@ -46,15 +64,6 @@ Metrics/CyclomaticComplexity:
cases needed to validate a method. cases needed to validate a method.
Enabled: true Enabled: true
Max: 6 Max: 6
Metrics/LineLength:
Description: Limit lines to 80 characters.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#80-character-limits
Enabled: true
Max: 100
AllowURI: true
URISchemes:
- http
- https
Metrics/MethodLength: Metrics/MethodLength:
Description: Avoid methods longer than 10 lines of code. Description: Avoid methods longer than 10 lines of code.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
@ -82,21 +91,27 @@ Metrics/PerceivedComplexity:
Enabled: true Enabled: true
Max: 7 Max: 7
Rails/ScopeArgs: Naming/AccessorMethodName:
Description: Checks the arguments of ActiveRecord scopes. Description: Check the naming of accessor methods for get_/set_.
Enabled: false
Naming/FileName:
Description: Use snake_case for source file names.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
Enabled: true Enabled: true
Rails/TimeZone: Exclude: []
# The value `strict` means that `Time` should be used with `zone`. Naming/PredicateName:
# The value `flexible` allows usage of `in_time_zone` instead of `zone`. Description: Check the names of predicate methods.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
Enabled: true Enabled: true
EnforcedStyle: flexible NamePrefix:
SupportedStyles: - is_
- strict - has_
- flexible - have_
ForbiddenPrefixes:
- is_
Exclude:
- spec/**/*
Style/AccessorMethodName:
Description: Check the naming of accessor methods for get_/set_.
Enabled: false
Style/AndOr: Style/AndOr:
Description: Use &&/|| instead of and/or. Description: Use &&/|| instead of and/or.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-and-or-or StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-and-or-or
@ -127,14 +142,6 @@ Style/CollectionMethods:
Style/Documentation: Style/Documentation:
Description: Document classes and non-namespace modules. Description: Document classes and non-namespace modules.
Enabled: false Enabled: false
Style/DotPosition:
Description: Checks the position of the dot in multi-line method calls.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
Enabled: true
EnforcedStyle: trailing
SupportedStyles:
- leading
- trailing
Style/DoubleNegation: Style/DoubleNegation:
Description: Checks for uses of double negation (!!). Description: Checks for uses of double negation (!!).
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
@ -146,11 +153,6 @@ Style/EmptyLiteral:
Description: Prefer literals to Array.new/Hash.new/String.new. Description: Prefer literals to Array.new/Hash.new/String.new.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
Enabled: true Enabled: true
Style/FileName:
Description: Use snake_case for source file names.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
Enabled: true
Exclude: []
Style/GuardClause: Style/GuardClause:
Description: Check for conditionals that can be replaced with guard clauses Description: Check for conditionals that can be replaced with guard clauses
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
@ -160,7 +162,6 @@ Style/IfUnlessModifier:
Description: Favor modifier if/unless usage when you have a single-line body. Description: Favor modifier if/unless usage when you have a single-line body.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
Enabled: false Enabled: false
MaxLineLength: 80
Style/InlineComment: Style/InlineComment:
Description: Avoid inline comments. Description: Avoid inline comments.
Enabled: false Enabled: false
@ -193,18 +194,6 @@ Style/PerlBackrefs:
Description: Avoid Perl-style regex back references. Description: Avoid Perl-style regex back references.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
Enabled: false Enabled: false
Style/PredicateName:
Description: Check the names of predicate methods.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
Enabled: true
NamePrefix:
- is_
- has_
- have_
NamePrefixBlacklist:
- is_
Exclude:
- spec/**/*
Style/RaiseArgs: Style/RaiseArgs:
Description: Checks the arguments passed to raise/fail. Description: Checks the arguments passed to raise/fail.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
@ -272,7 +261,16 @@ Style/TrailingCommaInArguments:
- comma - comma
- consistent_comma - consistent_comma
- no_comma - no_comma
Style/TrailingCommaInLiteral: Style/TrailingCommaInArrayLiteral:
Description: 'Checks for trailing comma in array and hash literals.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
Enabled: true
EnforcedStyleForMultiline: no_comma
SupportedStyles:
- comma
- consistent_comma
- no_comma
Style/TrailingCommaInHashLiteral:
Description: 'Checks for trailing comma in array and hash literals.' Description: 'Checks for trailing comma in array and hash literals.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
Enabled: true Enabled: true

21
Gemfile

@ -1,31 +1,34 @@
# frozen_string_literal: true
source 'https://rubygems.org' source 'https://rubygems.org'
# Specify your gem's dependencies in devise_ip_filter.gemspec # Specify your gem's dependencies in devise_ip_filter.gemspec
gemspec gemspec
rails_version = ENV["RAILS_VERSION"] || "default" rails_version = ENV['RAILS_VERSION'] || 'default'
rails = case rails_version rails = case rails_version
when "master" when 'master'
{github: "rails/rails"} { github: 'rails/rails' }
when "default" when 'default'
"~> 7.0.1" '~> 7.0.1'
else else
"~> #{rails_version}" "~> #{rails_version}"
end end
gem "rails", rails gem 'rails', rails
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0') if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
gem "test-unit", "~> 3.0" gem 'test-unit', '~> 3.0'
end end
group :test, :development do group :test, :development do
gem 'sqlite3' gem 'pry'
gem 'sprockets-rails' gem 'sprockets-rails'
gem 'sqlite3'
end end
group :test do group :test do
gem 'rack_session_access'
gem 'ammeter' gem 'ammeter'
gem 'rack_session_access'
end end

12
Rakefile

@ -1,14 +1,16 @@
require "bundler/gem_tasks" # frozen_string_literal: true
APP_RAKEFILE = File.expand_path("../spec/rails_app/Rakefile", __FILE__) require 'bundler/gem_tasks'
APP_RAKEFILE = File.expand_path('spec/rails_app/Rakefile', __dir__)
load 'rails/tasks/engine.rake' load 'rails/tasks/engine.rake'
require 'rspec/core/rake_task' require 'rspec/core/rake_task'
desc "Run all specs in spec directory (excluding plugin specs)" desc 'Run all specs in spec directory (excluding plugin specs)'
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare') RSpec::Core::RakeTask.new(spec: 'app:db:test:prepare')
task :default => :spec task default: :spec
# To test against a specific version of Rails # To test against a specific version of Rails
# export RAILS_VERSION=3.2.0; bundle update; rake # export RAILS_VERSION=3.2.0; bundle update; rake

4
spec/rails_app/Rakefile

@ -1,7 +1,9 @@
#!/usr/bin/env rake #!/usr/bin/env rake
# frozen_string_literal: true
# Add your own tasks in files placed in lib/tasks ending in .rake, # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__) require File.expand_path('config/application', __dir__)
Dummy::Application.load_tasks Dummy::Application.load_tasks

9
spec/rails_app/script/rails

@ -1,6 +1,9 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. # frozen_string_literal: true
APP_PATH = File.expand_path('../../config/application', __FILE__) # This command will automatically be run when you run "rails" with Rails 3
require File.expand_path('../../config/boot', __FILE__) # gems installed from the root of your application.
APP_PATH = File.expand_path('../config/application', __dir__)
require File.expand_path('../config/boot', __dir__)
require 'rails/commands' require 'rails/commands'

Loading…
Cancel
Save