Skip to content

Commit 26b2926

Browse files
justin808claude
andcommitted
Fix CI linting and syntax errors
- Fix critical regex syntax error in process_manager.rb (escaped square brackets) - Consolidate duplicate branch conditions in base_generator.rb and file_manager.rb - Fix shadowed exception warning in install_generator.rb (use Gem::LoadError only) - Apply RuboCop auto-corrections for string literals and layout issues - Improve RSpec spec to avoid stdout/stderr mutation anti-patterns - Run prettier formatting on all JavaScript/TypeScript files All RuboCop violations resolved - 134 files inspected, 0 offenses detected. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 2f1e98d commit 26b2926

File tree

7 files changed

+16
-31
lines changed

7 files changed

+16
-31
lines changed

lib/generators/react_on_rails/base_generator.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,9 @@ def install_js_dependencies
129129
run "yarn install"
130130
elsif File.exist?(File.join(destination_root, "pnpm-lock.yaml"))
131131
run "pnpm install"
132-
elsif File.exist?(File.join(destination_root, "package-lock.json"))
133-
run "npm install"
134-
elsif File.exist?(File.join(destination_root, "package.json"))
135-
# Default to npm if no lock file exists but package.json does
132+
elsif File.exist?(File.join(destination_root, "package-lock.json")) ||
133+
File.exist?(File.join(destination_root, "package.json"))
134+
# Use npm for package-lock.json or as default fallback
136135
run "npm install"
137136
end
138137
end

lib/generators/react_on_rails/install_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def ensure_shakapacker_installed
121121
def shakapacker_installed?
122122
Gem::Specification.find_by_name("shakapacker")
123123
true
124-
rescue Gem::MissingSpecError, Gem::LoadError
124+
rescue Gem::LoadError
125125
false
126126
end
127127

lib/react_on_rails/dev/file_manager.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,12 @@ def overmind_running?
5555
def process_running?(pid)
5656
Process.kill(0, pid)
5757
true
58-
rescue Errno::ESRCH
58+
rescue Errno::ESRCH, ArgumentError, RangeError
59+
# Process doesn't exist or invalid PID
5960
false
6061
rescue Errno::EPERM
6162
# Process exists but we don't have permission to signal it
6263
true
63-
rescue ArgumentError, RangeError
64-
# Invalid PID (negative, too large, wrong type)
65-
false
6664
end
6765

6866
def remove_file_if_exists(file_path, description)

lib/react_on_rails/dev/process_manager.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Dev
55
class ProcessManager
66
class << self
77
def installed?(process)
8-
IO.popen([process, "-v"]) { |io| io.close }
8+
IO.popen([process, "-v"], &:close)
99
true
1010
rescue Errno::ENOENT
1111
false
@@ -48,11 +48,11 @@ def run_with_process_manager(procfile)
4848

4949
def valid_procfile_path?(procfile)
5050
# Reject paths with shell metacharacters
51-
return false if procfile.match?(/[;&|`$(){}[\]<>]/)
51+
return false if procfile.match?(/[;&|`$(){}\[\]<>]/)
5252

5353
# Ensure it's a readable file
5454
File.readable?(procfile)
55-
rescue
55+
rescue StandardError
5656
false
5757
end
5858
end

rakelib/run_rspec.rake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ def run_tests_in(dir, options = {})
122122

123123
# Build environment variables as an array for proper spacing
124124
env_tokens = []
125-
env_tokens << options.fetch(:env_vars, '').strip unless options.fetch(:env_vars, '').strip.empty?
125+
env_tokens << options.fetch(:env_vars, "").strip unless options.fetch(:env_vars, "").strip.empty?
126126
env_tokens << "TEST_ENV_COMMAND_NAME=\"#{command_name}\""
127127
env_tokens << "COVERAGE=true" if ENV["USE_COVERALLS"]
128128

129-
env_vars = env_tokens.join(' ')
129+
env_vars = env_tokens.join(" ")
130130
sh_in_dir(path.realpath, "#{env_vars} bundle exec rspec #{rspec_args}")
131131
end

spec/dummy/spec/support/selenium_logger.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
err_msg.include?("This version of ChromeDriver has not been tested with Chrome version")
4040
end
4141

42-
raise("JavaScript error#{"s" if clean_errors.length > 0} on the page:\n\n#{clean_errors.join("\n")}") if clean_errors.present?
42+
if clean_errors.present?
43+
raise("JavaScript error#{'s' unless clean_errors.empty?} on the page:\n\n#{clean_errors.join("\n")}")
44+
end
4345
end
4446
end

spec/react_on_rails/dev/pack_generator_spec.rb

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,19 @@
44
require "react_on_rails/dev/pack_generator"
55

66
RSpec.describe ReactOnRails::Dev::PackGenerator do
7-
# Suppress stdout/stderr during tests using around hook
8-
around do |example|
9-
original_stderr = $stderr
10-
original_stdout = $stdout
11-
begin
12-
$stderr = File.open(File::NULL, "w")
13-
$stdout = File.open(File::NULL, "w")
14-
example.run
15-
ensure
16-
$stderr = original_stderr
17-
$stdout = original_stdout
18-
end
19-
end
20-
217
describe ".generate" do
228
it "runs pack generation successfully in verbose mode" do
239
command = "bundle exec rake react_on_rails:generate_packs"
2410
allow(Kernel).to receive(:system).with(command).and_return(true)
2511

26-
expect { described_class.generate(verbose: true) }.not_to raise_error
12+
expect { described_class.generate(verbose: true) }.to output.to_stdout_from_any_process
2713
end
2814

2915
it "runs pack generation successfully in quiet mode" do
3016
command = "bundle exec rake react_on_rails:generate_packs > /dev/null 2>&1"
3117
allow(Kernel).to receive(:system).with(command).and_return(true)
3218

33-
expect { described_class.generate(verbose: false) }.not_to raise_error
19+
expect { described_class.generate(verbose: false) }.not_to output.to_stdout_from_any_process
3420
end
3521

3622
it "exits with error when pack generation fails" do

0 commit comments

Comments
 (0)