rubosquad 0.2.1 → 0.3.0

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rubosquad.rb +18 -18
  3. metadata +60 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea0148cd8d05e66b5990557a84a80ff89fa053929e4bbec510aafbc12007e9ff
4
- data.tar.gz: fd638cb0a18a6a1b0dc77495b38c9b55dadee1045fbba4f79a6ea74b4c59bb62
3
+ metadata.gz: 7c7e515c37ec988ae40363c20d82bd911112e580920665ad87f38ccd0ef8fbe9
4
+ data.tar.gz: b17f9273f4485d9fa36a37401ac39fe5a69b7d4c174ed841f52c71c70a32e423
5
5
  SHA512:
6
- metadata.gz: e7878218fff87254f16cd8e6c54613301ca65c5ccf39cffd0b420cb0bb6eb7411a3bdf0991436acb634b353e3f2aa86726f9e1176ffc537b97b02e946b5dc7b2
7
- data.tar.gz: d89bd634df027b5ce0cc35d9e91e3349d5ef936d15cb9883eb500ba8fda11faeee33f0de7c7e4504bb8f0d7bd21ad37de58078ce94c5b4a76fcfbb48033ad6a0
6
+ metadata.gz: e9b19ee533958d0fba40237227f1f9b495d2deb6a45d37dddf964a6d0b6ea5ae7cacf0925bd6552d68b6b8ec865fc0004ed341d9fd38648150c7366601385da2
7
+ data.tar.gz: 8221ae12809121e8b9198fb7c6794d09db8af8e6fbfed1f1561a1979ae71e923184a2ebf6202b43930cd631f3aaa01936e211a477edc7dfad09e9bcc289942f2
data/lib/rubosquad.rb CHANGED
@@ -11,8 +11,8 @@ module Rubosquad
11
11
  options = {}
12
12
  OptionParser.new do |opts|
13
13
  opts.banner = 'Usage: rubosquad [options]'
14
- opts.on('-a', '--auto-correct', 'Run with rubocop -a instead of -A') do
15
- options[:auto_correct] = true
14
+ opts.on('-A', '--unsafe-auto-correct', 'Run with rubocop -A (unsafe auto-corrections) instead of -a') do
15
+ options[:unsafe_auto_correct] = true
16
16
  end
17
17
  end.parse!
18
18
 
@@ -20,7 +20,7 @@ module Rubosquad
20
20
  base_branch = detect_base_branch
21
21
 
22
22
  unless base_branch
23
- puts 'Error: Could not find main or master branch.'
23
+ Rails.logger.debug 'Error: Could not find main or master branch.'
24
24
  exit 1
25
25
  end
26
26
 
@@ -28,7 +28,7 @@ module Rubosquad
28
28
  current_branch = `git rev-parse --abbrev-ref HEAD`.strip
29
29
 
30
30
  if current_branch == base_branch
31
- puts "Warning: You are on the #{base_branch} branch. Comparing working directory changes."
31
+ Rails.logger.debug "Warning: You are on the #{base_branch} branch. Comparing working directory changes."
32
32
  # Compare working directory + staged changes against HEAD
33
33
  changed_files = `git diff --name-only HEAD`.split("\n")
34
34
  changed_files += `git diff --name-only --cached`.split("\n")
@@ -42,7 +42,7 @@ module Rubosquad
42
42
  changed_files = changed_files.select { |file| File.exist?(file) }
43
43
 
44
44
  if changed_files.empty?
45
- puts 'No Ruby files have changed.'
45
+ Rails.logger.debug 'No Ruby files have changed.'
46
46
  exit 0
47
47
  end
48
48
 
@@ -52,9 +52,9 @@ module Rubosquad
52
52
  "#{current_branch} vs #{base_branch}"
53
53
  end
54
54
 
55
- puts "\nRunning Rubocop on changed files (#{comparison_info}):"
55
+ Rails.logger.debug "\nRunning Rubocop on changed files (#{comparison_info}):"
56
56
  changed_files.each { |file| puts " - #{file}" }
57
- puts
57
+ Rails.logger.debug
58
58
 
59
59
  # Check for available RuboCop extensions that can actually be loaded
60
60
  extensions = %w[rubocop-factory_bot rubocop-rails rubocop-rspec rubocop-rspec_rails]
@@ -67,15 +67,15 @@ module Rubosquad
67
67
 
68
68
  # Construct the RuboCop command
69
69
 
70
- rubocop_option = options[:auto_correct] ? '-a' : '-A'
70
+ rubocop_option = options[:unsafe_auto_correct] ? '-A' : '-a'
71
71
  command = "rubocop #{rubocop_option} --format offenses --format simple #{available_extensions.map do |ext|
72
72
  "--require #{ext}"
73
73
  end.join(' ')} #{changed_files.join(' ')}"
74
74
 
75
75
  stdout, stderr, status = Open3.capture3(command)
76
76
 
77
- puts "\nRubocop Output:"
78
- puts '==Error type: Legend: C = Convention, W = Warning, E = Error, F = Fatal=='
77
+ Rails.logger.debug "\nRubocop Output:"
78
+ Rails.logger.debug '==Error type: Legend: C = Convention, W = Warning, E = Error, F = Fatal=='
79
79
 
80
80
  # Process and colorize output
81
81
  processed_output = ''
@@ -102,26 +102,26 @@ module Rubosquad
102
102
  end
103
103
  end
104
104
 
105
- puts processed_output
105
+ Rails.logger.debug processed_output
106
106
 
107
107
  if status.success?
108
- puts "\nRubocop auto-corrections complete."
108
+ Rails.logger.debug "\nRubocop auto-corrections complete."
109
109
  else
110
- puts "\nRubocop completed with offenses:"
110
+ Rails.logger.debug "\nRubocop completed with offenses:"
111
111
 
112
112
  offenses = stdout.scan(/(\d+) offense.* detected/)
113
113
  total_offenses = offenses.flatten.map(&:to_i).sum
114
114
 
115
- puts "Files inspected: #{stdout[/(\d+) files? inspected/, 1] || 'Unknown'}"
116
- puts "Total offenses detected: #{total_offenses}"
115
+ Rails.logger.debug "Files inspected: #{stdout[/(\d+) files? inspected/, 1] || 'Unknown'}"
116
+ Rails.logger.debug "Total offenses detected: #{total_offenses}"
117
117
 
118
118
  unless stderr.strip.empty?
119
- puts "\nStandard error:"
120
- puts stderr
119
+ Rails.logger.debug "\nStandard error:"
120
+ Rails.logger.debug stderr
121
121
  end
122
122
  end
123
123
 
124
- puts "\nRuboCop extensions used: #{available_extensions.join(', ')}"
124
+ Rails.logger.debug "\nRuboCop extensions used: #{available_extensions.join(', ')}"
125
125
  end
126
126
 
127
127
  # Detect the base branch to compare against
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubosquad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - LucasWaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-23 00:00:00.000000000 Z
11
+ date: 2025-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -16,14 +16,70 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '1.50'
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.0'
26
+ version: '1.50'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop-factory_bot
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-rspec_rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
27
83
  description: A tool to run RuboCop with auto-correct on Ruby files changed in your
28
84
  Git branch compared to main
29
85
  email: lucas.waki@cloudwalk.io