Skip to content

Commit

Permalink
Merge pull request #126 from testdouble/2-7-support
Browse files Browse the repository at this point in the history
2.7 support
  • Loading branch information
searls authored Jul 9, 2019
2 parents 759f6f1 + 309e201 commit 536b43c
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 220 deletions.
17 changes: 9 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
PATH
remote: .
specs:
standard (0.0.41)
rubocop (~> 0.67.1)
standard (0.1.0)
rubocop (~> 0.72.0)
rubocop-performance (~> 1.4.0)

GEM
remote: https://rubygems.org/
Expand All @@ -21,24 +22,24 @@ GEM
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
psych (3.1.0)
rainbow (3.0.0)
rake (12.3.2)
rubocop (0.67.2)
rubocop (0.72.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
psych (>= 3.1.0)
parser (>= 2.6)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.6)
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-performance (1.4.0)
rubocop (>= 0.71.0)
ruby-progressbar (1.10.1)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
unicode-display_width (1.5.0)
unicode-display_width (1.6.0)

PLATFORMS
ruby
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ for details.

Because Standard wraps RuboCop, they share the same [runtime
requirements](https://github.com/rubocop-hq/rubocop#compatibility)—currently,
that's MRI 2.2 and newer. While Standard can't avoid this runtime requirement,
it does allow you to lint codebases that target Ruby versions older than 2.2 by
that's MRI 2.3 and newer. While Standard can't avoid this runtime requirement,
it does allow you to lint codebases that target Ruby versions older than 2.3 by
narrowing the ruleset somewhat.

Standard will default to telling RuboCop to target the currently running version
Expand All @@ -297,11 +297,11 @@ for an example.
It's a little confusing to consider, but the targeted Ruby version for linting
may or may not match the version of the runtime (suppose you're on Ruby 2.5.1,
but your library supports Ruby 2.2.0). In this case, specify `ruby_version` and
but your library supports Ruby 2.3.0). In this case, specify `ruby_version` and
you should be okay. However, note that if you target a _newer_ Ruby version than
the runtime, RuboCop may behave in surprising or inconsistent ways.
If you are targeting a Ruby older than 2.2 and run into an issue, check out
If you are targeting a Ruby older than 2.3 and run into an issue, check out
Standard's [version-specific RuboCop
configurations](https://github.com/testdouble/standard/tree/master/config) and
consider helping out by submitting a pull request if you find a rule that won't
Expand Down
206 changes: 8 additions & 198 deletions config/base.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
require:
- rubocop-performance

AllCops:
# Prevent RuboCop from exploding when it finds an older-than-2.2 .ruby-version
# Prevent RuboCop from exploding when it finds an older-than-2.3 .ruby-version
TargetRubyVersion: 2.5
DisabledByDefault: true
Exclude: []
Expand Down Expand Up @@ -138,12 +141,12 @@ Layout/ExtraSpacing:
AllowBeforeTrailingComments: false
ForceEqualSignAlignment: false

Layout/FirstParameterIndentation:
Layout/IndentFirstArgument:
Enabled: true
EnforcedStyle: consistent
IndentationWidth: ~

Layout/IndentArray:
Layout/IndentFirstArrayElement:
Enabled: true
EnforcedStyle: consistent
IndentationWidth: ~
Expand All @@ -152,14 +155,14 @@ Layout/IndentAssignment:
Enabled: true
IndentationWidth: ~

Layout/IndentHash:
Layout/IndentFirstHashElement:
Enabled: true
EnforcedStyle: consistent
IndentationWidth: ~

Layout/IndentHeredoc:
Enabled: true
EnforcedStyle: auto_detection
EnforcedStyle: squiggly

Layout/IndentationConsistency:
Enabled: true
Expand Down Expand Up @@ -631,199 +634,6 @@ Performance/UnfreezeString:
Performance/UriDefaultParser:
Enabled: true

Rails/ActionFilter:
Enabled: true
EnforcedStyle: action
Include:
- app/controllers/**/*.rb

Rails/ActiveRecordAliases:
Enabled: true

Rails/ActiveSupportAliases:
Enabled: true

Rails/ApplicationJob:
Enabled: true

Rails/ApplicationRecord:
Enabled: true

Rails/AssertNot:
Enabled: true
Include:
- '**/test/**/*'

Rails/Blank:
Enabled: true
# 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:
Enabled: true
Database: null
Include:
- db/migrate/*.rb

Rails/CreateTableWithTimestamps:
Enabled: true
Include:
- db/migrate/*.rb

Rails/Date:
Enabled: true
EnforcedStyle: flexible

Rails/Delegate:
Enabled: true
EnforceForPrefixed: true

Rails/DelegateAllowBlank:
Enabled: true

Rails/DynamicFindBy:
Enabled: true
Whitelist:
- find_by_sql

Rails/EnumUniqueness:
Enabled: true
Include:
- app/models/**/*.rb

Rails/EnvironmentComparison:
Enabled: true

Rails/Exit:
Enabled: true
Include:
- app/**/*.rb
- config/**/*.rb
- lib/**/*.rb
Exclude:
- lib/**/*.rake

Rails/FilePath:
Enabled: true
EnforcedStyle: arguments

Rails/FindBy:
Enabled: true
Include:
- app/models/**/*.rb

Rails/FindEach:
Enabled: true
Include:
- app/models/**/*.rb

Rails/HasAndBelongsToMany:
Enabled: true
Include:
- app/models/**/*.rb

Rails/HttpPositionalArguments:
Enabled: true
Include:
- 'spec/**/*'
- 'test/**/*'

Rails/HttpStatus:
Enabled: true
EnforcedStyle: symbolic

Rails/InverseOf:
Enabled: true
Include:
- app/models/**/*.rb

Rails/LexicallyScopedActionFilter:
Enabled: true
Safe: false
Include:
- app/controllers/**/*.rb

Rails/NotNullColumn:
Enabled: true
Include:
- db/migrate/*.rb

Rails/Output:
Enabled: true
Include:
- app/**/*.rb
- config/**/*.rb
- db/**/*.rb
- lib/**/*.rb

Rails/OutputSafety:
Enabled: true

Rails/PluralizationGrammar:
Enabled: true

Rails/Presence:
Enabled: true

Rails/Present:
Enabled: true
NotNilAndNotEmpty: true
NotBlank: true
UnlessBlank: true

Rails/ReadWriteAttribute:
Enabled: true
Include:
- app/models/**/*.rb

Rails/RedundantReceiverInWithOptions:
Enabled: true

Rails/RefuteMethods:
Enabled: true
Include:
- '**/test/**/*'

Rails/RelativeDateConstant:
Enabled: true
AutoCorrect: false

Rails/RequestReferer:
Enabled: true
EnforcedStyle: referer

Rails/ReversibleMigration:
Enabled: true
Include:
- db/migrate/*.rb

Rails/SafeNavigation:
Enabled: true
ConvertTry: false

Rails/ScopeArgs:
Enabled: true
Include:
- app/models/**/*.rb

Rails/TimeZone:
Enabled: true
EnforcedStyle: flexible

Rails/UniqBeforePluck:
Enabled: true
EnforcedStyle: conservative
AutoCorrect: false

Rails/Validation:
Enabled: true
Include:
- app/models/**/*.rb

Security/Eval:
Enabled: true

Expand Down
2 changes: 1 addition & 1 deletion config/ruby-2.2.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
inherit_from: ./base.yml

AllCops:
TargetRubyVersion: 2.2
TargetRubyVersion: 2.3 # The oldest supported

Layout:
IndentHeredoc:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def call(options_config, standard_config)
private

def max_rubocop_supported_version(desired_version)
rubocop_supported_version = Gem::Version.new("2.2")
rubocop_supported_version = Gem::Version.new("2.3")
if desired_version < rubocop_supported_version
rubocop_supported_version
else
Expand Down
2 changes: 1 addition & 1 deletion lib/standard/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Standard
VERSION = Gem::Version.new("0.0.41")
VERSION = Gem::Version.new("0.1.0")
end
3 changes: 2 additions & 1 deletion standard.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency "rubocop", "~> 0.67.1"
spec.add_dependency "rubocop", "~> 0.72.0"
spec.add_dependency "rubocop-performance", "~> 1.4.0"

spec.add_development_dependency "bundler", "~> 1.17"
spec.add_development_dependency "minitest", "~> 5.0"
Expand Down
2 changes: 2 additions & 0 deletions test/fixture/runner/agreeable.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

def add(left, right)
left + right
end
2 changes: 1 addition & 1 deletion test/standard/builds_config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_19

assert_equal DEFAULT_OPTIONS, result.rubocop_options

assert_equal config_store("test/fixture/config/w", "config/ruby-1.9.yml", 2.2), result.rubocop_config_store.for("").to_h
assert_equal config_store("test/fixture/config/w", "config/ruby-1.9.yml", 2.3), result.rubocop_config_store.for("").to_h
end

def test_specified_standard_yaml_overrides_local
Expand Down
2 changes: 1 addition & 1 deletion test/standard/detects_fixability_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_returns_true_when_offense_is_autocorrectable
end

def test_can_find_a_config_option_for_everything_we_prescribe_with_asploding
our_cop_names = YAML.load_file("config/base.yml").keys - ["AllCops"]
our_cop_names = YAML.load_file("config/base.yml").keys - ["AllCops", "require"]

result = @subject.call(our_cop_names.map { |cop_name| Offense.new(cop_name) })

Expand Down
11 changes: 7 additions & 4 deletions test/standard/runners/rubocop_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,17 @@ def test_print_corrected_output_on_stdin

expected_out = <<-OUT.gsub(/^ {6}/, "")
== test/fixture/runner/agreeable.rb ==
C: 1: 1: [Corrected] Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
C: 1: 1: [Corrected] Style/SingleLineMethods: Avoid single-line method definitions.
C: 1: 5: Naming/MethodName: Use snake_case for method names.
C: 1: 8: [Corrected] Layout/SpaceAfterSemicolon: Space missing after semicolon.
C: 1: 8: [Corrected] Style/Semicolon: Do not use semicolons to terminate expressions.
C: 1: 9: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
C: 3: 5: Naming/MethodName: Use snake_case for method names.
C: 3: 8: [Corrected] Style/Semicolon: Do not use semicolons to terminate expressions.
C: 3: 9: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
1 file inspected, 5 offenses detected, 4 offenses corrected
1 file inspected, 6 offenses detected, 5 offenses corrected
====================
# frozen_string_literal: true
def Foo
'hi'
end
Expand Down

0 comments on commit 536b43c

Please sign in to comment.