rubocop-gradual 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad8fc07a5efc9411a388f7fd1eab366bacd44466ea7d268596b22d2c8a42522c
4
- data.tar.gz: 618f6421cca7465ec6b3bfa08fd0a97eda8cf642c605ec8010a944f406d7b8bd
3
+ metadata.gz: 750548fbcac00bd48721d0c3f1b0b7a43b5cf77aaafe7a81d6f58bfbe6edc2e6
4
+ data.tar.gz: dfba66113c744a92a51b6c72e6bec157c12dd721cee9d8a1d033a0845b4bf0ab
5
5
  SHA512:
6
- metadata.gz: 14a9f2ae2e16a42171257db3d466eb99228e2a094c4e453725a3e07136f09a6d028bd080e158da47efbdbd012e57e8641ee259ff296df388f8515e3da14cbc23
7
- data.tar.gz: f8c0d7a36a2f616893bbcdc681f775989b3b376ecdacc6383bdb8ca417fd08b82f06d9f19955b3c2decbb32d4f159fb2957f47b0a518ae22fb29f48e11fa4f4c
6
+ metadata.gz: d713758f60a7b2ee780aeafda2fb01c6eb2f68f5a97aa521da5b1ef57a5a33bf3d3fa05b9dfb0f9d231ac3f0d107b72b7af1260eb9e76f6ae259bc3a619d1190
7
+ data.tar.gz: 1e4286b97788902cfc101698cb31ae756a70c2419d824ae3b547db1eb060a2cc36e6fc6eb334007658ef3c0ffec8ba484b257770d0e025768c1bf70aef58e419
data/CHANGELOG.md CHANGED
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning].
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.3.5] - 2024-06-24
11
+
12
+ ### Added
13
+
14
+ - Add support for the RuboCop `--list` option. ([@skryukov])
15
+
16
+ ### Fixed
17
+
18
+ - Respect files passed to RuboCop in required mode. ([@skryukov])
19
+ - Exclude deleted files when running `--staged`. ([@dmorgan-fa])
20
+ - Don't show "EVEN BETTER" instruction when all issues are fixed. ([@skryukov])
21
+
22
+ ## [0.3.4] - 2023-10-26
23
+
24
+ ### Fixed
25
+
26
+ - Use JSON.dump instead of to_json for stable results encoding. ([@skryukov])
27
+
10
28
  ## [0.3.3] - 2023-10-18
11
29
 
12
30
  ### Fixed
@@ -97,9 +115,12 @@ RuboCop::Gradual::RakeTask.new
97
115
 
98
116
  - Initial implementation. ([@skryukov])
99
117
 
118
+ [@dmorgan-fa]: https://github.com/dmorgan-fa
100
119
  [@skryukov]: https://github.com/skryukov
101
120
 
102
- [Unreleased]: https://github.com/skryukov/rubocop-gradual/compare/v0.3.3...HEAD
121
+ [Unreleased]: https://github.com/skryukov/rubocop-gradual/compare/v0.3.5...HEAD
122
+ [0.3.5]: https://github.com/skryukov/rubocop-gradual/compare/v0.3.4...v0.3.5
123
+ [0.3.4]: https://github.com/skryukov/rubocop-gradual/compare/v0.3.3...v0.3.4
103
124
  [0.3.3]: https://github.com/skryukov/rubocop-gradual/compare/v0.3.2...v0.3.3
104
125
  [0.3.2]: https://github.com/skryukov/rubocop-gradual/compare/v0.3.1...v0.3.2
105
126
  [0.3.1]: https://github.com/skryukov/rubocop-gradual/compare/v0.3.0...v0.3.1
@@ -10,11 +10,19 @@ module RuboCop
10
10
  def run(argv = ARGV)
11
11
  Configuration.apply(*Options.new.parse(argv))
12
12
  puts "Gradual mode: #{Configuration.mode}" if Configuration.debug?
13
- load_command(Configuration.command).call.to_i
13
+ cmd = load_command(Configuration.command)
14
+ return list_target_files(cmd) if Configuration.rubocop_options[:list_target_files]
15
+
16
+ cmd.call.to_i
14
17
  end
15
18
 
16
19
  private
17
20
 
21
+ def list_target_files(cmd)
22
+ cmd.lint_paths.each { |path| puts PathUtil.relative_path(path) }
23
+ 1
24
+ end
25
+
18
26
  def load_command(command)
19
27
  require_relative "commands/#{command}"
20
28
  ::RuboCop::Gradual::Commands.const_get(command.to_s.capitalize).new
@@ -20,14 +20,14 @@ module RuboCop
20
20
  Base.new.call
21
21
  end
22
22
 
23
- private
24
-
25
23
  def lint_paths
26
24
  return Configuration.target_file_paths if Configuration.lint_paths.any?
27
25
 
28
26
  changed_or_untracked_files.map(&:path)
29
27
  end
30
28
 
29
+ private
30
+
31
31
  def changed_or_untracked_files
32
32
  tracked_files = LockFile.new(Configuration.path).read_results&.files || []
33
33
 
@@ -23,6 +23,10 @@ module RuboCop
23
23
  1
24
24
  end
25
25
 
26
+ def lint_paths
27
+ Configuration.target_file_paths
28
+ end
29
+
26
30
  private
27
31
 
28
32
  def run_rubocop
@@ -36,12 +40,6 @@ module RuboCop
36
40
  rubocop_runner.run
37
41
  end
38
42
 
39
- def lint_paths
40
- return [] if Configuration.lint_paths.empty?
41
-
42
- Configuration.target_file_paths
43
- end
44
-
45
43
  def rubocop_options
46
44
  Configuration.rubocop_options
47
45
  .slice(:config, :debug, :display_time)
@@ -14,7 +14,7 @@ module RuboCop
14
14
  when :unstaged
15
15
  `git ls-files --others --exclude-standard -m`.split("\n")
16
16
  when :staged
17
- `git diff --cached --name-only`.split("\n")
17
+ `git diff --cached --name-only --diff-filter=d`.split("\n") # excludes deleted files
18
18
  else
19
19
  `git diff --name-only #{commit}`.split("\n")
20
20
  end
@@ -9,23 +9,22 @@ module RuboCop
9
9
  def run_command(name)
10
10
  return super if name != :execute_runner || (ARGV & %w[--stdin -s]).any?
11
11
 
12
- Configuration.apply(*parse_options)
13
- puts "Gradual mode: #{Configuration.mode}" if Configuration.debug?
14
- load_command(Configuration.command).call.to_i
12
+ RuboCop::Gradual::CLI.new.run(patched_argv)
15
13
  end
16
14
 
17
15
  private
18
16
 
19
- def load_command(command)
20
- require_relative "commands/#{command}"
21
- ::RuboCop::Gradual::Commands.const_get(command.to_s.capitalize).new
22
- end
17
+ def patched_argv
18
+ return ARGV if ARGV[0] != "gradual"
23
19
 
24
- def parse_options
25
- options, rubocop_options = Options.new.parse(ARGV)
26
- options[:mode] = :force_update if @env.paths[0..1] == %w[gradual force_update]
27
- options[:mode] = :check if @env.paths[0..1] == %w[gradual check]
28
- [options, rubocop_options]
20
+ case ARGV[1]
21
+ when "force_update"
22
+ ARGV[2..] + ["--force-update"]
23
+ when "check"
24
+ ARGV[2..] + ["--check"]
25
+ else
26
+ raise ArgumentError, "Unknown gradual command #{ARGV[1]}"
27
+ end
29
28
  end
30
29
  end
31
30
  end
@@ -12,16 +12,19 @@ module RuboCop
12
12
  def print_results
13
13
  puts diff.statistics if Configuration.debug?
14
14
 
15
- send "print_#{diff.state}"
15
+ send :"print_#{diff.state}"
16
16
  end
17
17
 
18
- def print_ci_warning(diff)
18
+ def print_ci_warning(diff, statistics:)
19
19
  puts <<~MSG
20
20
  \n#{bold("Unexpected Changes!")}
21
21
 
22
22
  RuboCop Gradual lock file is outdated, to fix this message:
23
- - Run `rubocop-gradual` locally and commit the results, or
24
- - EVEN BETTER: before doing the above, try to fix the remaining issues in those files!
23
+ - Run `rubocop-gradual` locally and commit the results#{
24
+ if statistics[:unchanged] != statistics[:left]
25
+ ", or\n- EVEN BETTER: before doing the above, try to fix the remaining issues in those files!"
26
+ end
27
+ }
25
28
 
26
29
  #{bold("`#{Configuration.path}` diff:")}
27
30
 
@@ -23,7 +23,9 @@ module RuboCop
23
23
  printer = Printer.new(diff)
24
24
 
25
25
  printer.print_results
26
- printer.print_ci_warning(lock_file.diff(new_results)) if fail_with_outdated_lock?(diff)
26
+ if fail_with_outdated_lock?(diff)
27
+ printer.print_ci_warning(lock_file.diff(new_results), statistics: diff.statistics)
28
+ end
27
29
 
28
30
  exit_code = error_code(diff)
29
31
  sync_lock_file(diff) if exit_code.zero?
@@ -20,7 +20,7 @@ module RuboCop
20
20
  end
21
21
 
22
22
  def to_s
23
- "[#{[line, column, length, message.to_json, code_hash].join(", ")}]"
23
+ "[#{[line, column, length, JSON.dump(message), code_hash].join(", ")}]"
24
24
  end
25
25
 
26
26
  def ==(other)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Gradual
5
- VERSION = "0.3.3"
5
+ VERSION = "0.3.5"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-gradual
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Svyatoslav Kryukov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-18 00:00:00.000000000 Z
11
+ date: 2024-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
154
  requirements: []
155
- rubygems_version: 3.3.7
155
+ rubygems_version: 3.5.7
156
156
  signing_key:
157
157
  specification_version: 4
158
158
  summary: Gradual RuboCop plugin