standard 1.3.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/config/ruby-1.8.yml CHANGED
@@ -5,3 +5,9 @@ Style/HashSyntax:
5
5
 
6
6
  Style/Lambda:
7
7
  Enabled: false
8
+
9
+ Style/FileWrite:
10
+ Enabled: false
11
+
12
+ Style/FileRead:
13
+ Enabled: false
data/config/ruby-2.2.yml CHANGED
@@ -3,3 +3,6 @@ inherit_from: ./ruby-2.3.yml
3
3
  Layout:
4
4
  HeredocIndentation:
5
5
  Enabled: false
6
+
7
+ Performance/ConcurrentMonotonicTime:
8
+ Enabled: false
data/config/ruby-2.5.yml CHANGED
@@ -1,4 +1,4 @@
1
- inherit_from: ./ruby-2.7.yml
1
+ inherit_from: ./ruby-2.6.yml
2
2
 
3
3
  AllCops:
4
4
  TargetRubyVersion: 2.5
@@ -0,0 +1,10 @@
1
+ inherit_from: ./ruby-2.7.yml
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.6
5
+
6
+ Style/NumberedParameters:
7
+ Enabled: false
8
+
9
+ Style/NumberedParametersLimit:
10
+ Enabled: false
@@ -0,0 +1,10 @@
1
+ inherit_from: ./base.yml
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 3.0
5
+
6
+ Style/HashExcept:
7
+ Enabled: true
8
+
9
+ Naming/BlockForwarding:
10
+ Enabled: false
@@ -10,7 +10,11 @@ class Standard::CreatesConfigStore
10
10
  private
11
11
 
12
12
  def rubocop_yaml_path(desired_version)
13
- file_name = if desired_version < Gem::Version.new("1.9")
13
+ default = "base.yml"
14
+
15
+ file_name = if !Gem::Version.correct?(desired_version)
16
+ default
17
+ elsif desired_version < Gem::Version.new("1.9")
14
18
  "ruby-1.8.yml"
15
19
  elsif desired_version < Gem::Version.new("2.0")
16
20
  "ruby-1.9.yml"
@@ -25,7 +29,7 @@ class Standard::CreatesConfigStore
25
29
  elsif desired_version < Gem::Version.new("3.0")
26
30
  "ruby-2.7.yml"
27
31
  else
28
- "base.yml"
32
+ default
29
33
  end
30
34
 
31
35
  Pathname.new(__dir__).join("../../../config/#{file_name}")
@@ -1,7 +1,7 @@
1
1
  class Standard::CreatesConfigStore
2
2
  class SetsTargetRubyVersion
3
3
  def call(options_config, standard_config)
4
- options_config["AllCops"]["TargetRubyVersion"] = floatify_version(
4
+ options_config["AllCops"]["TargetRubyVersion"] = normalize_version(
5
5
  max_rubocop_supported_version(standard_config[:ruby_version])
6
6
  )
7
7
  end
@@ -9,6 +9,8 @@ class Standard::CreatesConfigStore
9
9
  private
10
10
 
11
11
  def max_rubocop_supported_version(desired_version)
12
+ return desired_version unless Gem::Version.correct?(desired_version)
13
+
12
14
  rubocop_supported_version = Gem::Version.new("2.5")
13
15
  if desired_version < rubocop_supported_version
14
16
  rubocop_supported_version
@@ -17,7 +19,9 @@ class Standard::CreatesConfigStore
17
19
  end
18
20
  end
19
21
 
20
- def floatify_version(version)
22
+ def normalize_version(version)
23
+ return version unless Gem::Version.correct?(version)
24
+
21
25
  major, minor = version.segments
22
26
  "#{major}.#{minor}".to_f # lol
23
27
  end
@@ -19,6 +19,7 @@ module Standard
19
19
  @detects_fixability = DetectsFixability.new
20
20
  @header_printed_already = false
21
21
  @fix_suggestion_printed_already = false
22
+ @offenses_encountered = false
22
23
  end
23
24
 
24
25
  def started(_target_files)
@@ -26,7 +27,11 @@ module Standard
26
27
  end
27
28
 
28
29
  def file_finished(file, offenses)
29
- return unless (uncorrected_offenses = offenses.reject(&:corrected?)).any?
30
+ uncorrected_offenses = offenses.reject(&:corrected?)
31
+
32
+ return unless uncorrected_offenses.any?
33
+
34
+ @offenses_encountered = true
30
35
 
31
36
  print_header_once
32
37
  print_fix_suggestion_once(uncorrected_offenses)
@@ -36,6 +41,10 @@ module Standard
36
41
  end
37
42
  end
38
43
 
44
+ def finished(inspected_files)
45
+ print_todo_congratulations
46
+ end
47
+
39
48
  private
40
49
 
41
50
  def print_header_once
@@ -64,7 +73,7 @@ module Standard
64
73
  return unless todo_file
65
74
 
66
75
  todo_ignore_files = options[:todo_ignore_files]
67
- return unless todo_ignore_files
76
+ return unless todo_ignore_files&.any?
68
77
 
69
78
  output.print <<-HEADER.gsub(/^ {8}/, "")
70
79
  WARNING: this project is being migrated to standard gradually via `#{todo_file}` and is ignoring these files:
@@ -75,6 +84,20 @@ module Standard
75
84
  end
76
85
  end
77
86
 
87
+ def print_todo_congratulations
88
+ return if @offenses_encountered
89
+
90
+ todo_file = options[:todo_file]
91
+ return unless todo_file
92
+
93
+ todo_ignore_files = options[:todo_ignore_files]
94
+ return if todo_ignore_files&.any?
95
+
96
+ output.print <<-HEADER.gsub(/^ {8}/, "")
97
+ Congratulations, you've successfully migrated this project to Standard! Delete `#{todo_file}` in celebration.
98
+ HEADER
99
+ end
100
+
78
101
  def path_to(file)
79
102
  Pathname.new(file).relative_path_from(Pathname.new(Dir.pwd))
80
103
  end
@@ -24,7 +24,7 @@ module Standard
24
24
 
25
25
  def construct_config(yaml_path, standard_yaml, todo_path, todo_yaml)
26
26
  {
27
- ruby_version: Gem::Version.new((standard_yaml["ruby_version"] || RUBY_VERSION)),
27
+ ruby_version: normalized_ruby_version(standard_yaml["ruby_version"]),
28
28
  fix: !!standard_yaml["fix"],
29
29
  format: standard_yaml["format"],
30
30
  parallel: !!standard_yaml["parallel"],
@@ -36,6 +36,12 @@ module Standard
36
36
  }
37
37
  end
38
38
 
39
+ def normalized_ruby_version(version)
40
+ return version if version && !Gem::Version.correct?(version)
41
+
42
+ Gem::Version.new(version || RUBY_VERSION)
43
+ end
44
+
39
45
  def expand_ignore_config(ignore_config)
40
46
  arrayify(ignore_config).map { |rule|
41
47
  if rule.is_a?(String)
@@ -1,3 +1,3 @@
1
1
  module Standard
2
- VERSION = Gem::Version.new("1.3.0")
2
+ VERSION = Gem::Version.new("1.7.0")
3
3
  end
data/standard.gemspec CHANGED
@@ -19,6 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "rubocop", "1.20.0"
23
- spec.add_dependency "rubocop-performance", "1.11.5"
22
+ spec.add_dependency "rubocop", "1.25.0"
23
+ spec.add_dependency "rubocop-performance", "1.13.2"
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Searls
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-27 00:00:00.000000000 Z
11
+ date: 2022-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.20.0
19
+ version: 1.25.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.20.0
26
+ version: 1.25.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubocop-performance
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 1.11.5
33
+ version: 1.13.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 1.11.5
40
+ version: 1.13.2
41
41
  description:
42
42
  email:
43
43
  - searls@gmail.com
@@ -46,7 +46,9 @@ executables:
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
+ - ".github/dependabot.yml"
49
50
  - ".github/workflows/test.yml"
51
+ - ".github/workflows/update.yml"
50
52
  - ".gitignore"
51
53
  - ".standard.yml"
52
54
  - CHANGELOG.md
@@ -64,7 +66,9 @@ files:
64
66
  - config/ruby-2.3.yml
65
67
  - config/ruby-2.4.yml
66
68
  - config/ruby-2.5.yml
69
+ - config/ruby-2.6.yml
67
70
  - config/ruby-2.7.yml
71
+ - config/ruby-3.0.yml
68
72
  - docs/RELEASE.md
69
73
  - exe/standardrb
70
74
  - lib/standard.rb