Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmartian committed Jan 24, 2024
1 parent 4b3dfed commit eef2f16
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 15 deletions.
12 changes: 10 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Style/Documentation:
Enabled: false

# To fix later
Style/FormatStringToken:
Enabled: false
Style/PercentLiteralDelimiters:
Enabled: false
Style/VariableNumber:
Expand All @@ -73,7 +75,13 @@ Style/EmptyMethod:
Enabled: false
Style/SymbolArray:
Enabled: false
Style/IndentHeredoc:
Style/YodaCondition:
Enabled: false
Layout/HeredocIndentation:
Enabled: false
Layout/ExtraSpacing:
Enabled: false
Performance/Caller:
Enabled: false
Style/ExtraSpacing:
Style/WordArray:
Enabled: false
2 changes: 1 addition & 1 deletion lib/octocatalog-diff/api/v1/override.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def convert_to_data_type(datatype, value)
return value if datatype == 'string'
return parse_json(value) if datatype == 'json'
return nil if datatype == 'nil'
if datatype == 'fixnum' || datatype == 'integer'
if ['fixnum', 'integer'].include? datatype
return Regexp.last_match(1).to_i if value =~ /^(-?\d+)$/
raise ArgumentError, "Illegal integer '#{value}'"
end
Expand Down
6 changes: 3 additions & 3 deletions lib/octocatalog-diff/catalog-diff/differ.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def filter_and_cleanup(catalog_resources)
# Process each attribute in the resource
resource.each do |k, v|
# Title was pre-processed
next if k == 'title' || k == 'type'
next if ['title', 'type'].include? k

# Handle parameters
if k == 'parameters'
Expand All @@ -272,7 +272,7 @@ def filter_and_cleanup(catalog_resources)
# The order of tags is unimportant. Sort this array to avoid false diffs if order changes.
# Also if tags is empty, don't add.
hsh[k] = v.sort if v.is_a?(Array) && v.any?
elsif k == 'file' || k == 'line'
elsif ['file', 'line'].include? k
# We don't care, for the purposes of catalog-diff, from which manifest and line this resource originated.
# However, we may report this to the user, so we will keep it in here for now.
hsh[k] = v
Expand Down Expand Up @@ -354,7 +354,7 @@ def attr_match_rule?(rule, attrib, old_val, new_val)
elsif operator == '=->'
# String equality test only of the old value
matcher = ->(x, _y) { x == value }
elsif operator == '=~>' || operator == '=&>'
elsif ['=~>', '=&>'].include? operator
begin
my_regex = Regexp.new(value, Regexp::IGNORECASE)
rescue RegexpError => exc
Expand Down
2 changes: 1 addition & 1 deletion lib/octocatalog-diff/cli/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def self.option_classes
# option will populate any of the 'to' and 'from' variants that are missing.
# @param :datatype [?] Expected data type
def self.option_globally_or_per_branch(opts = {})
opts[:filename] = caller[0].split(':').first
opts[:filename] = opts[:filename] = caller[0].split(':').first
datatype = opts.fetch(:datatype, '')
return option_globally_or_per_branch_string(opts) if datatype.is_a?(String)
return option_globally_or_per_branch_array(opts) if datatype.is_a?(Array)
Expand Down
2 changes: 1 addition & 1 deletion lib/octocatalog-diff/cli/options/compare_file_text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def parse(parser, options)
parser.on('--[no-]compare-file-text[=force]', 'Compare text, not source location, of file resources') do |x|
if x == 'force'
options[:compare_file_text] = :force
elsif x == true || x == false
elsif [true, false].include? x
options[:compare_file_text] = x
else
raise OptionParser::NeedlessArgument("needless argument: --compare-file-text=#{x}")
Expand Down
8 changes: 4 additions & 4 deletions octocatalog-diff.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Gem::Specification.new do |s|
s.homepage = 'https://github.com/github/octocatalog-diff'
s.summary = 'Compile Puppet catalogs from 2 branches, versions, etc., and compare them.'
s.description = <<-EOF
Octocatalog-Diff assists with Puppet development and testing by enabling the user to
compile 2 Puppet catalogs and compare them. It is possible to compare different
branches, different versions, and different fact values. This is intended to be run
from a local development environment or in CI.
Octocatalog-Diff assists with Puppet development and testing by enabling the user to
compile 2 Puppet catalogs and compare them. It is possible to compare different
branches, different versions, and different fact values. This is intended to be run
from a local development environment or in CI.
EOF

s.add_runtime_dependency 'diffy', '>= 3.1.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ def catalog_from_fixture(path)
it 'should expand globs in modulepath, if present' do
allow(File).to receive(:file?).with('/a/environment.conf').and_return(true)
allow(File).to receive(:read).with('/a/environment.conf')
.and_return('modulepath=modules:extra_mods/*/modules:$basemoduledir')
.and_return('modulepath=modules:extra_mods/*/modules:$basemoduledir')
allow(Dir).to receive(:glob).with('/a/modules').and_return(['/a/modules'])
allow(Dir).to receive(:glob).with('/a/extra_mods/*/modules')
.and_return(['/a/extra_mods/a/modules', '/a/extra_mods/b/modules'])
.and_return(['/a/extra_mods/a/modules', '/a/extra_mods/b/modules'])
result = OctocatalogDiff::CatalogUtil::FileResources.module_path('/a')
expect(result).to eq(['/a/modules', '/a/extra_mods/a/modules', '/a/extra_mods/b/modules'])
end
Expand Down
4 changes: 3 additions & 1 deletion spec/octocatalog-diff/tests/catalog-util/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@
it 'should return the sha from rugged' do
opts = { branch: 'foo', basedir: '/tmp/bar' }
expect(Rugged::Repository).to receive(:new).with('/tmp/bar')
.and_return(OpenStruct.new(branches: { 'foo' => OpenStruct.new(target_id: 'abcdef012345') }))
.and_return(OpenStruct.new(branches: {
'foo' => OpenStruct.new(target_id: 'abcdef012345')
}))
result = described_class.branch_sha(opts)
expect(result).to eq('abcdef012345')
end
Expand Down

0 comments on commit eef2f16

Please sign in to comment.