Skip to content

Commit b30dce9

Browse files
committed
improve ruby syntax check and fix fail_on_warnings usage
1 parent 5834684 commit b30dce9

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
### 2.4.0 (Next)
2+
- Minimum Ruby version increased to 3.0.
23
- Fix `rubocop-performance` inclusion warning.
34
- Improve recognition of Ruby support files during filesystem parsing.
45
- Fix `file` task for no settings override usage.
5-
- Minimum Ruby version increased to 3.0.
66
- Add `rubocop-rspec` plugin to Ruby checks.
7+
- Fix `--fail-on-warnings` functionality.
8+
- Improve safety of Ruby syntax checks.
79

810
### 2.3.1
911
- No input target paths now defaults to current working directory instead of error.

lib/puppet-check/ruby_parser.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ def self.ruby(files, style, rc_args)
1717

1818
files.each do |file|
1919
# check ruby syntax
20-
# prevents ruby code from actually executing the input ruby file
21-
catch(:good) { instance_eval("BEGIN {throw :good}; #{File.read(file)} # BEGIN {throw :good}; ruby_file_content", file) }
20+
RubyVM::InstructionSequence.compile_file(file)
2221
rescue ScriptError, StandardError => err
2322
PuppetCheck.files[:errors][file] = err.to_s.gsub("#{file}:", '').split("\n")
2423
else

lib/puppet_check.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def run(settings = {}, paths = [])
3333
OutputResults.run(parsed_files.clone, settings[:output_format])
3434

3535
# progress to regression checks if no errors in file checks
36-
if parsed_files[:errors].empty? && (!settings[:fail_on_warning] || parsed_files[:warnings].empty?)
36+
if parsed_files[:errors].empty? && (!settings[:fail_on_warnings] || parsed_files[:warnings].empty?)
3737
begin
3838
require_relative 'puppet-check/regression_check'
3939

0 commit comments

Comments
 (0)