Skip to content

Commit 9cf2d7f

Browse files
committed
code style updates
1 parent 683ba2b commit 9cf2d7f

File tree

5 files changed

+36
-25
lines changed

5 files changed

+36
-25
lines changed

.rubocop.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,37 @@ AllCops:
1616
- 'spec/fixtures/**/*'
1717
- 'bin/puppet'
1818

19+
# twenty-first century
1920
Metrics:
2021
Enabled: false
2122

2223
Layout/LineLength:
2324
Enabled: false
2425

26+
# why
2527
Layout/EmptyLineAfterGuardClause:
2628
Enabled: false
2729

30+
# poor coding practices
2831
Naming/RescuedExceptionsVariableName:
2932
Enabled: false
3033

31-
# false triggers for this cop
34+
# false triggers
3235
Style/EvalWithLocation:
3336
Enabled: false
3437

35-
# probably can remove after rails cops removed from core
38+
# false positives
3639
Style/FrozenStringLiteralComment:
3740
Enabled: false
3841

42+
# why
3943
Style/ClassAndModuleChildren:
4044
Enabled: false
4145

46+
# poor practices
4247
Gemspec/DevelopmentDependencies:
4348
Enabled: false
49+
50+
# encourages unreadable code
51+
Style/IfUnlessModifier:
52+
Enabled: false

spec/puppet-check/data_parser_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
it 'puts a bad syntax yaml file in the error files hash' do
1616
DataParser.yaml(["#{fixtures_dir}hieradata/syntax.yaml"])
1717
expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}hieradata/syntax.yaml"])
18-
expect(PuppetCheck.files[:errors]["#{fixtures_dir}hieradata/syntax.yaml"].join("\n")).to match(%r{^block sequence entries are not allowed})
18+
expect(PuppetCheck.files[:errors]["#{fixtures_dir}hieradata/syntax.yaml"].join("\n")).to match(/^block sequence entries are not allowed/)
1919
expect(PuppetCheck.files[:warnings]).to eql({})
2020
expect(PuppetCheck.files[:clean]).to eql([])
2121
end
2222
it 'puts a good yaml file with potential hiera issues in the warning files array' do
2323
DataParser.yaml(["#{fixtures_dir}hieradata/style.yaml"])
2424
expect(PuppetCheck.files[:errors]).to eql({})
2525
expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}hieradata/style.yaml"])
26-
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}hieradata/style.yaml"].join("\n")).to match(%r{^Value\(s\) missing in key.*\nValue\(s\) missing in key.*\nThe string --- appears more than once in this data and Hiera may fail to parse it correctly})
26+
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}hieradata/style.yaml"].join("\n")).to match(/^Value\(s\) missing in key.*\nValue\(s\) missing in key.*\nThe string --- appears more than once in this data and Hiera may fail to parse it correctly/)
2727
expect(PuppetCheck.files[:clean]).to eql([])
2828
end
2929
it 'puts a good yaml file in the clean files array' do
@@ -47,15 +47,15 @@
4747
it 'puts a bad syntax eyaml file in the error files hash' do
4848
DataParser.eyaml(["#{fixtures_dir}hieradata/syntax.eyaml"], "#{fixtures_dir}keys/public_key.pkcs7.pem", "#{fixtures_dir}keys/private_key.pkcs7.pem")
4949
expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}hieradata/syntax.eyaml"])
50-
expect(PuppetCheck.files[:errors]["#{fixtures_dir}hieradata/syntax.eyaml"].join("\n")).to match(%r{^block sequence entries are not allowed})
50+
expect(PuppetCheck.files[:errors]["#{fixtures_dir}hieradata/syntax.eyaml"].join("\n")).to match(/^block sequence entries are not allowed/)
5151
expect(PuppetCheck.files[:warnings]).to eql({})
5252
expect(PuppetCheck.files[:clean]).to eql([])
5353
end
5454
it 'puts a good eyaml file with potential hiera issues in the warning files array' do
5555
DataParser.eyaml(["#{fixtures_dir}hieradata/style.eyaml"], "#{fixtures_dir}keys/public_key.pkcs7.pem", "#{fixtures_dir}keys/private_key.pkcs7.pem")
5656
expect(PuppetCheck.files[:errors]).to eql({})
5757
expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}hieradata/style.eyaml"])
58-
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}hieradata/style.eyaml"].join("\n")).to match(%r{^Value\(s\) missing in key.*\nValue\(s\) missing in key.*\nThe string --- appears more than once in this data and Hiera may fail to parse it correctly})
58+
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}hieradata/style.eyaml"].join("\n")).to match(/^Value\(s\) missing in key.*\nValue\(s\) missing in key.*\nThe string --- appears more than once in this data and Hiera may fail to parse it correctly/)
5959
expect(PuppetCheck.files[:clean]).to eql([])
6060
end
6161
it 'puts a good eyaml file in the clean files array' do
@@ -70,22 +70,22 @@
7070
it 'puts a bad syntax json file in the error files hash' do
7171
DataParser.json(["#{fixtures_dir}hieradata/syntax.json"])
7272
expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}hieradata/syntax.json"])
73-
expect(PuppetCheck.files[:errors]["#{fixtures_dir}hieradata/syntax.json"].join("\n")).to match(%r{^.*unexpected token})
73+
expect(PuppetCheck.files[:errors]["#{fixtures_dir}hieradata/syntax.json"].join("\n")).to match(/^.*unexpected token/)
7474
expect(PuppetCheck.files[:warnings]).to eql({})
7575
expect(PuppetCheck.files[:clean]).to eql([])
7676
end
7777
it 'puts a bad metadata json file in the error files hash' do
7878
DataParser.json(["#{fixtures_dir}metadata_syntax/metadata.json"])
7979
expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}metadata_syntax/metadata.json"])
80-
expect(PuppetCheck.files[:errors]["#{fixtures_dir}metadata_syntax/metadata.json"].join("\n")).to match(%r{^Required field.*\nField 'requirements'.*\nDuplicate dependencies.*\nDeprecated field.*\nSummary exceeds})
80+
expect(PuppetCheck.files[:errors]["#{fixtures_dir}metadata_syntax/metadata.json"].join("\n")).to match(/^Required field.*\nField 'requirements'.*\nDuplicate dependencies.*\nDeprecated field.*\nSummary exceeds/)
8181
expect(PuppetCheck.files[:warnings]).to eql({})
8282
expect(PuppetCheck.files[:clean]).to eql([])
8383
end
8484
it 'puts a bad style metadata json file in the warning files array' do
8585
DataParser.json(["#{fixtures_dir}metadata_style/metadata.json"])
8686
expect(PuppetCheck.files[:errors]).to eql({})
8787
expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}metadata_style/metadata.json"])
88-
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}metadata_style/metadata.json"].join("\n")).to match(%r{^'pe' is missing an upper bound.\n.*operatingsystem_support.*\nLicense identifier})
88+
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}metadata_style/metadata.json"].join("\n")).to match(/^'pe' is missing an upper bound.\n.*operatingsystem_support.*\nLicense identifier/)
8989
expect(PuppetCheck.files[:clean]).to eql([])
9090
end
9191
it 'puts another bad style metadata json file in the warning files array' do
@@ -99,7 +99,7 @@
9999
DataParser.json(["#{fixtures_dir}task_metadata/task_bad.json"])
100100
expect(PuppetCheck.files[:errors]).to eql({})
101101
expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}task_metadata/task_bad.json"])
102-
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}task_metadata/task_bad.json"].join("\n")).to match(%r{^description value is not a String\ninput_method value is not one of environment, stdin, or powershell\nparameters value is not a Hash\npuppet_task_version value is not an Integer\nsupports_noop value is not a Boolean})
102+
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}task_metadata/task_bad.json"].join("\n")).to match(/^description value is not a String\ninput_method value is not one of environment, stdin, or powershell\nparameters value is not a Hash\npuppet_task_version value is not an Integer\nsupports_noop value is not a Boolean/)
103103
expect(PuppetCheck.files[:clean]).to eql([])
104104
end
105105
it 'puts a good json file in the clean files array' do

spec/puppet-check/puppet_parser_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
PuppetParser.manifest(["#{fixtures_dir}manifests/syntax.pp"], false, [])
1717
expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}manifests/syntax.pp"])
1818
if Gem::Version.new(Puppet::PUPPETVERSION) >= Gem::Version.new('6.5.0')
19-
expect(PuppetCheck.files[:errors]["#{fixtures_dir}manifests/syntax.pp"].join("\n")).to match(%r{^Language validation logged 2 errors})
19+
expect(PuppetCheck.files[:errors]["#{fixtures_dir}manifests/syntax.pp"].join("\n")).to match(/^Language validation logged 2 errors/)
2020
else
21-
expect(PuppetCheck.files[:errors]["#{fixtures_dir}hieradata/syntax.yaml"].join("\n")).to match(%r{^This Variable has no effect.*\nIllegal variable name})
21+
expect(PuppetCheck.files[:errors]["#{fixtures_dir}hieradata/syntax.yaml"].join("\n")).to match(/^This Variable has no effect.*\nIllegal variable name/)
2222
end
2323
expect(PuppetCheck.files[:warnings]).to eql({})
2424
expect(PuppetCheck.files[:clean]).to eql([])
@@ -28,30 +28,30 @@
2828
it 'puts a bad syntax at eof Puppet manifest in the error files hash' do
2929
PuppetParser.manifest(["#{fixtures_dir}manifests/eof_syntax.pp"], false, [])
3030
expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}manifests/eof_syntax.pp"])
31-
expect(PuppetCheck.files[:errors]["#{fixtures_dir}manifests/eof_syntax.pp"].join("\n")).to match(%r{^Syntax error at end of input})
31+
expect(PuppetCheck.files[:errors]["#{fixtures_dir}manifests/eof_syntax.pp"].join("\n")).to match(/^Syntax error at end of input/)
3232
expect(PuppetCheck.files[:warnings]).to eql({})
3333
expect(PuppetCheck.files[:clean]).to eql([])
3434
end
3535
end
3636
it 'puts a bad syntax Puppet plan in the error files hash' do
3737
PuppetParser.manifest(["#{fixtures_dir}plans/syntax.pp"], false, [])
3838
expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}plans/syntax.pp"])
39-
expect(PuppetCheck.files[:errors]["#{fixtures_dir}plans/syntax.pp"].join("\n")).to match(%r{^Syntax error at '\)'})
39+
expect(PuppetCheck.files[:errors]["#{fixtures_dir}plans/syntax.pp"].join("\n")).to match(/^Syntax error at '\)'/)
4040
expect(PuppetCheck.files[:warnings]).to eql({})
4141
expect(PuppetCheck.files[:clean]).to eql([])
4242
end
4343
it 'puts a bad parser style and lint style Puppet manifest in the warning files array' do
4444
PuppetParser.manifest(["#{fixtures_dir}manifests/style_parser.pp"], true, [])
4545
expect(PuppetCheck.files[:errors]).to eql({})
4646
expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}manifests/style_parser.pp"])
47-
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}manifests/style_parser.pp"].join("\n")).to match(%r{^Unrecognized escape sequence.*\nUnrecognized escape sequence.*\n.*double quoted string containing})
47+
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}manifests/style_parser.pp"].join("\n")).to match(/^Unrecognized escape sequence.*\nUnrecognized escape sequence.*\n.*double quoted string containing/)
4848
expect(PuppetCheck.files[:clean]).to eql([])
4949
end
5050
it 'puts a bad lint style Puppet manifest in the warning files array' do
5151
PuppetParser.manifest(["#{fixtures_dir}manifests/style_lint.pp"], true, [])
5252
expect(PuppetCheck.files[:errors]).to eql({})
5353
expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}manifests/style_lint.pp"])
54-
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}manifests/style_lint.pp"].join("\n")).to match(%r{(?:indentation of|double quoted string containing).*\n.*(?:indentation of|double quoted string containing)})
54+
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}manifests/style_lint.pp"].join("\n")).to match(/(?:indentation of|double quoted string containing).*\n.*(?:indentation of|double quoted string containing)/)
5555
expect(PuppetCheck.files[:clean]).to eql([])
5656
end
5757
it 'puts a bad style Puppet manifest in the clean files array when puppetlint_args ignores its warnings' do
@@ -64,7 +64,7 @@
6464
PuppetParser.manifest(["#{fixtures_dir}plans/style.pp"], true, [])
6565
expect(PuppetCheck.files[:errors]).to eql({})
6666
expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}plans/style.pp"])
67-
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}plans/style.pp"].join("\n")).to match(%r{variable not enclosed in {}})
67+
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}plans/style.pp"].join("\n")).to match(/variable not enclosed in {}/)
6868
expect(PuppetCheck.files[:clean]).to eql([])
6969
end
7070
it 'puts a good Puppet manifest in the clean files array' do
@@ -88,7 +88,7 @@
8888
it 'puts a bad syntax Puppet template in the error files hash' do
8989
PuppetParser.template(["#{fixtures_dir}templates/syntax.epp"])
9090
expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}templates/syntax.epp"])
91-
expect(PuppetCheck.files[:errors]["#{fixtures_dir}templates/syntax.epp"].join("\n")).to match(%r{^This Name has no effect})
91+
expect(PuppetCheck.files[:errors]["#{fixtures_dir}templates/syntax.epp"].join("\n")).to match(/^This Name has no effect/)
9292
expect(PuppetCheck.files[:warnings]).to eql({})
9393
expect(PuppetCheck.files[:clean]).to eql([])
9494
end

spec/puppet-check/regression_check_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
expect { RegressionCheck.config("#{octocatalog_diff_dir}octocatalog_diff.cfg.rb") }.not_to raise_exception
1313
end
1414
it 'loads in the settings from the file correctly' do
15+
# TODO
1516
end
1617
end
1718

@@ -31,5 +32,6 @@
3132
end
3233

3334
context '.regression' do
35+
# TODO
3436
end
3537
end

spec/puppet-check/ruby_parser_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
it 'puts a bad syntax ruby file in the error files hash' do
1616
RubyParser.ruby(["#{fixtures_dir}lib/syntax.rb"], false, [])
1717
expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}lib/syntax.rb"])
18-
expect(PuppetCheck.files[:errors]["#{fixtures_dir}lib/syntax.rb"].join("\n")).to match(%r{^.*syntax error})
18+
expect(PuppetCheck.files[:errors]["#{fixtures_dir}lib/syntax.rb"].join("\n")).to match(/^.*syntax error/)
1919
expect(PuppetCheck.files[:warnings]).to eql({})
2020
expect(PuppetCheck.files[:clean]).to eql([])
2121
end
2222
it 'puts a bad style ruby file in the warning files array' do
2323
RubyParser.ruby(["#{fixtures_dir}lib/style.rb"], true, [])
2424
expect(PuppetCheck.files[:errors]).to eql({})
2525
expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}lib/style.rb"])
26-
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}lib/style.rb"].join("\n")).to match(%r{Useless assignment.*\n.*Use the new.*\n.*Do not introduce.*\n.*Prefer single.*\n.*Remove unnecessary empty.*\n.*Source code comment is empty.*\n.*is a writable attribute.*\n.*Issue has no descriptive comment})
26+
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}lib/style.rb"].join("\n")).to match(/Useless assignment.*\n.*Use the new.*\n.*Do not introduce.*\n.*Prefer single.*\n.*Remove unnecessary empty.*\n.*Source code comment is empty.*\n.*is a writable attribute.*\n.*Issue has no descriptive comment/)
2727
expect(PuppetCheck.files[:clean]).to eql([])
2828
end
2929
it 'puts a bad style ruby file in the clean files array when rubocop_args ignores its warnings' do
@@ -45,9 +45,9 @@
4545
RubyParser.template(["#{fixtures_dir}templates/syntax.erb"])
4646
expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}templates/syntax.erb"])
4747
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
48-
expect(PuppetCheck.files[:errors]["#{fixtures_dir}templates/syntax.erb"].join("\n")).to match(%r{1: syntax error, unexpected.*\n.*ruby})
48+
expect(PuppetCheck.files[:errors]["#{fixtures_dir}templates/syntax.erb"].join("\n")).to match(/1: syntax error, unexpected.*\n.*ruby/)
4949
else
50-
expect(PuppetCheck.files[:errors]["#{fixtures_dir}templates/syntax.erb"].join("\n")).to match(%r{syntax error, unexpected tIDENTIFIER})
50+
expect(PuppetCheck.files[:errors]["#{fixtures_dir}templates/syntax.erb"].join("\n")).to match(/syntax error, unexpected tIDENTIFIER/)
5151
end
5252
expect(PuppetCheck.files[:warnings]).to eql({})
5353
expect(PuppetCheck.files[:clean]).to eql([])
@@ -56,7 +56,7 @@
5656
RubyParser.template(["#{fixtures_dir}templates/style.erb"])
5757
expect(PuppetCheck.files[:errors]).to eql({})
5858
expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}templates/style.erb"])
59-
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}templates/style.erb"].join("\n")).to match(%r{already initialized constant.*\n.*previous definition of})
59+
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}templates/style.erb"].join("\n")).to match(/already initialized constant.*\n.*previous definition of/)
6060
expect(PuppetCheck.files[:clean]).to eql([])
6161
end
6262
it 'puts a ruby template file with ignored errors in the clean files array' do
@@ -77,15 +77,15 @@
7777
it 'puts a bad syntax librarian Puppet file in the error files hash' do
7878
RubyParser.librarian(["#{fixtures_dir}librarian_syntax/Puppetfile"], false, [])
7979
expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}librarian_syntax/Puppetfile"])
80-
expect(PuppetCheck.files[:errors]["#{fixtures_dir}librarian_syntax/Puppetfile"].join("\n")).to match(%r{^.*syntax error})
80+
expect(PuppetCheck.files[:errors]["#{fixtures_dir}librarian_syntax/Puppetfile"].join("\n")).to match(/^.*syntax error/)
8181
expect(PuppetCheck.files[:warnings]).to eql({})
8282
expect(PuppetCheck.files[:clean]).to eql([])
8383
end
8484
it 'puts a bad style librarian Puppet file in the warning files array' do
8585
RubyParser.librarian(["#{fixtures_dir}librarian_style/Puppetfile"], true, [])
8686
expect(PuppetCheck.files[:errors]).to eql({})
8787
expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}librarian_style/Puppetfile"])
88-
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}librarian_style/Puppetfile"].join("\n")).to match(%r{Align the arguments.*\n.*Use the new})
88+
expect(PuppetCheck.files[:warnings]["#{fixtures_dir}librarian_style/Puppetfile"].join("\n")).to match(/Align the arguments.*\n.*Use the new/)
8989
expect(PuppetCheck.files[:clean]).to eql([])
9090
end
9191
it 'puts a bad style librarian Puppet file in the clean files array when rubocop_args ignores its warnings' do

0 commit comments

Comments
 (0)