diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9f1758c..acef15d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,25 +1,6 @@ name: CI on: [push, pull_request, workflow_dispatch] jobs: - puppet-3-8-7: - env: - PUPPET_VERSIONS: "3.8.7" - PUPPET_VERSION: "3.8.7" - RUBOCOP_TEST: false - RSPEC_TEST: true - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - ruby-version: ["2.0", "2.1"] - steps: - - name: Checkout code - uses: actions/checkout@v1 - - name: Build container - run: docker build . --file Dockerfile --tag octocatalog-diff:ruby${{matrix.ruby-version}} --build-arg RUBY_VERSION=${{matrix.ruby-version}} - - name: Tests - run: docker run -e PUPPET_VERSION -e PUPPET_VERSIONS -e RSPEC_TEST -e RUBOCOP_TEST -e ENFORCE_COVERAGE octocatalog-diff:ruby${{matrix.ruby-version}} /app/script/cibuild - puppet-4-10-10: env: PUPPET_VERSIONS: "4.10.10" @@ -30,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - ruby-version: ["2.1", "2.2", "2.3"] + ruby-version: ["2.5", "2.6"] steps: - name: Checkout code uses: actions/checkout@v1 @@ -39,22 +20,22 @@ jobs: - name: Tests run: docker run -e PUPPET_VERSION -e PUPPET_VERSIONS -e RSPEC_TEST -e RUBOCOP_TEST -e ENFORCE_COVERAGE octocatalog-diff:ruby${{matrix.ruby-version}} /app/script/cibuild - puppet-5-5-8: + puppet-5-5-22: env: - PUPPET_VERSIONS: "5.5.8" - PUPPET_VERSION: "5.5.8" + PUPPET_VERSIONS: "5.5.22" + PUPPET_VERSION: "5.5.22" RUBOCOP_TEST: false RSPEC_TEST: true runs-on: ubuntu-latest strategy: fail-fast: false matrix: - ruby-version: ["2.4", "2.5", "2.6"] + ruby-version: ["2.5", "2.6"] steps: - name: Checkout code uses: actions/checkout@v1 - name: Build container - run: docker build . --file Dockerfile --tag octocatalog-diff:ruby${{matrix.ruby-version}} --build-arg RUBY_VERSION=${{matrix.ruby-version}}-stretch + run: docker build . --file Dockerfile --tag octocatalog-diff:ruby${{matrix.ruby-version}} --build-arg RUBY_VERSION=${{matrix.ruby-version}}-buster - name: Tests run: docker run -e PUPPET_VERSION -e PUPPET_VERSIONS -e RSPEC_TEST -e RUBOCOP_TEST -e ENFORCE_COVERAGE octocatalog-diff:ruby${{matrix.ruby-version}} /app/script/cibuild @@ -73,7 +54,7 @@ jobs: - name: Checkout code uses: actions/checkout@v1 - name: Build container - run: docker build . --file Dockerfile --tag octocatalog-diff:ruby${{matrix.ruby-version}} --build-arg RUBY_VERSION=${{matrix.ruby-version}}-stretch + run: docker build . --file Dockerfile --tag octocatalog-diff:ruby${{matrix.ruby-version}} --build-arg RUBY_VERSION=${{matrix.ruby-version}}-buster - name: Tests run: docker run -e PUPPET_VERSION -e PUPPET_VERSIONS -e RSPEC_TEST -e RUBOCOP_TEST -e ENFORCE_COVERAGE octocatalog-diff:ruby${{matrix.ruby-version}} /app/script/cibuild - name: Rubocop and Coverage diff --git a/.rubocop.yml b/.rubocop.yml index 48f25aa..b606d74 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -57,6 +57,8 @@ Style/Documentation: Enabled: false # To fix later +Style/FormatStringToken: + Enabled: false Style/PercentLiteralDelimiters: Enabled: false Style/VariableNumber: @@ -73,7 +75,13 @@ Style/EmptyMethod: Enabled: false Style/SymbolArray: Enabled: false -Style/IndentHeredoc: +Style/YodaCondition: Enabled: false -Style/ExtraSpacing: +Layout/HeredocIndentation: + Enabled: false +Layout/ExtraSpacing: + Enabled: false +Performance/Caller: + Enabled: false +Style/WordArray: Enabled: false diff --git a/Gemfile b/Gemfile index 76de7e7..25df42a 100644 --- a/Gemfile +++ b/Gemfile @@ -2,5 +2,6 @@ source 'https://rubygems.org' gem 'rake', '12.3.3' gem 'httparty', '0.16.3' +gem 'rubocop', '0.49.0' gemspec diff --git a/lib/octocatalog-diff/api/v1/override.rb b/lib/octocatalog-diff/api/v1/override.rb index b6d56c2..8624c77 100644 --- a/lib/octocatalog-diff/api/v1/override.rb +++ b/lib/octocatalog-diff/api/v1/override.rb @@ -74,7 +74,7 @@ module OctocatalogDiff 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 diff --git a/lib/octocatalog-diff/catalog-diff/differ.rb b/lib/octocatalog-diff/catalog-diff/differ.rb index 37828b9..3d959fa 100644 --- a/lib/octocatalog-diff/catalog-diff/differ.rb +++ b/lib/octocatalog-diff/catalog-diff/differ.rb @@ -262,7 +262,7 @@ module OctocatalogDiff # 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' @@ -272,7 +272,7 @@ module OctocatalogDiff # 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 @@ -354,7 +354,7 @@ module OctocatalogDiff 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 diff --git a/lib/octocatalog-diff/cli/options.rb b/lib/octocatalog-diff/cli/options.rb index 155839e..e295642 100644 --- a/lib/octocatalog-diff/cli/options.rb +++ b/lib/octocatalog-diff/cli/options.rb @@ -99,7 +99,7 @@ module OctocatalogDiff # 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) diff --git a/lib/octocatalog-diff/cli/options/compare_file_text.rb b/lib/octocatalog-diff/cli/options/compare_file_text.rb index a5b465b..b189209 100644 --- a/lib/octocatalog-diff/cli/options/compare_file_text.rb +++ b/lib/octocatalog-diff/cli/options/compare_file_text.rb @@ -23,7 +23,7 @@ OctocatalogDiff::Cli::Options::Option.newoption(:compare_file_text) do 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}") diff --git a/octocatalog-diff.gemspec b/octocatalog-diff.gemspec index 118b9e2..4315fb7 100644 --- a/octocatalog-diff.gemspec +++ b/octocatalog-diff.gemspec @@ -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' @@ -31,11 +31,11 @@ EOF s.add_runtime_dependency 'rugged', '>= 0.25.0b2' s.add_development_dependency 'rspec', '~> 3.4.0' - s.add_development_dependency 'rake', '12.3.1' + s.add_development_dependency 'rake', '12.3.3' s.add_development_dependency 'parallel_tests', '2.7.1' s.add_development_dependency 'rspec-retry', '0.5.0' - s.add_development_dependency 'rubocop', '= 0.48.1' + s.add_development_dependency 'rubocop', '= 0.49.0' s.add_development_dependency 'simplecov', '~> 0.14.1' s.add_development_dependency 'simplecov-erb', '~> 0.1.1' diff --git a/spec/octocatalog-diff/tests/catalog-util/fileresources_spec.rb b/spec/octocatalog-diff/tests/catalog-util/fileresources_spec.rb index 10d3789..77c02a6 100644 --- a/spec/octocatalog-diff/tests/catalog-util/fileresources_spec.rb +++ b/spec/octocatalog-diff/tests/catalog-util/fileresources_spec.rb @@ -92,10 +92,10 @@ describe OctocatalogDiff::CatalogUtil::FileResources do 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 diff --git a/spec/octocatalog-diff/tests/catalog-util/git_spec.rb b/spec/octocatalog-diff/tests/catalog-util/git_spec.rb index 4f01fc9..2ca7575 100644 --- a/spec/octocatalog-diff/tests/catalog-util/git_spec.rb +++ b/spec/octocatalog-diff/tests/catalog-util/git_spec.rb @@ -96,7 +96,9 @@ describe OctocatalogDiff::CatalogUtil::Git do 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 diff --git a/vendor/cache/mime-types-3.5.2.gem b/vendor/cache/mime-types-3.5.2.gem new file mode 100644 index 0000000..57a6ae2 Binary files /dev/null and b/vendor/cache/mime-types-3.5.2.gem differ diff --git a/vendor/cache/mime-types-data-3.2023.1205.gem b/vendor/cache/mime-types-data-3.2023.1205.gem new file mode 100644 index 0000000..dbe83e6 Binary files /dev/null and b/vendor/cache/mime-types-data-3.2023.1205.gem differ diff --git a/vendor/cache/rubocop-0.49.0.gem b/vendor/cache/rubocop-0.49.0.gem new file mode 100644 index 0000000..ad7fa4c Binary files /dev/null and b/vendor/cache/rubocop-0.49.0.gem differ