From a715b7893ffdd693b6e3a6558548cfe1290e1677 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Wed, 19 Apr 2017 12:28:11 +0100 Subject: [PATCH 1/2] rubocop:auto_correct --- Rakefile | 2 +- lib/modulesync.rb | 4 ++-- lib/modulesync/git.rb | 2 +- modulesync.gemspec | 1 + spec/unit/modulesync/settings_spec.rb | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Rakefile b/Rakefile index e35c8c4a..39932da8 100644 --- a/Rakefile +++ b/Rakefile @@ -18,4 +18,4 @@ Cucumber::Rake::Task.new do |t| t.cucumber_opts << '--format pretty' end -task :test => [:clean, :spec, :cucumber, :rubocop] +task :test => %i[clean spec cucumber rubocop] diff --git a/lib/modulesync.rb b/lib/modulesync.rb index 6ed05f12..f40b5b76 100644 --- a/lib/modulesync.rb +++ b/lib/modulesync.rb @@ -49,7 +49,7 @@ def self.managed_modules(path, filter, negative_filter) exit end managed_modules.select! { |m| m =~ Regexp.new(filter) } unless filter.nil? - managed_modules.select! { |m| m !~ Regexp.new(negative_filter) } unless negative_filter.nil? + managed_modules.reject! { |m| m =~ Regexp.new(negative_filter) } unless negative_filter.nil? managed_modules end @@ -89,7 +89,7 @@ def self.manage_file(filename, settings, options) def self.manage_module(puppet_module, module_files, module_options, defaults, options) puts "Syncing #{puppet_module}" - namespace, module_name = self.module_name(puppet_module, options[:namespace]) + namespace, module_name = module_name(puppet_module, options[:namespace]) unless options[:offline] git_base = options[:git_base] git_uri = "#{git_base}#{namespace}" diff --git a/lib/modulesync/git.rb b/lib/modulesync/git.rb index 6bcf8663..4115538e 100644 --- a/lib/modulesync/git.rb +++ b/lib/modulesync/git.rb @@ -147,7 +147,7 @@ def self.update(name, files, options) def self.untracked_unignored_files(repo) ignore_path = "#{repo.dir.path}/.gitignore" ignored = File.exist?(ignore_path) ? File.open(ignore_path).read.split : [] - repo.status.untracked.keep_if { |f, _| !ignored.any? { |i| File.fnmatch(i, f) } } + repo.status.untracked.keep_if { |f, _| ignored.none? { |i| File.fnmatch(i, f) } } end def self.update_noop(name, options) diff --git a/modulesync.gemspec b/modulesync.gemspec index bde633df..1253e393 100644 --- a/modulesync.gemspec +++ b/modulesync.gemspec @@ -1,4 +1,5 @@ # coding: utf-8 + lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) diff --git a/spec/unit/modulesync/settings_spec.rb b/spec/unit/modulesync/settings_spec.rb index 6fb572cb..f4a0fe8e 100644 --- a/spec/unit/modulesync/settings_spec.rb +++ b/spec/unit/modulesync/settings_spec.rb @@ -19,7 +19,7 @@ it { expect(subject.managed?('Gemfile')).to eq true } it { expect(subject.managed?('Gemfile/foo')).to eq true } it { expect(subject.managed_files([])).to eq ['Gemfile'] } - it { expect(subject.managed_files(%w(Rakefile Gemfile other_file))).to eq %w(Gemfile other_file) } + it { expect(subject.managed_files(%w[Rakefile Gemfile other_file])).to eq %w[Gemfile other_file] } it { expect(subject.unmanaged_files([])).to eq ['Rakefile'] } - it { expect(subject.unmanaged_files(%w(Rakefile Gemfile other_file))).to eq ['Rakefile'] } + it { expect(subject.unmanaged_files(%w[Rakefile Gemfile other_file])).to eq ['Rakefile'] } end From 02f88d35bcb03353a315cb5b5423010cc43e64f2 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Wed, 19 Apr 2017 12:30:12 +0100 Subject: [PATCH 2/2] Disable Style/IndentHeredoc Fixing those complaints would require using an external library. --- .rubocop.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 81ed3ff9..d54a1b7b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -14,3 +14,7 @@ Style/HashSyntax: # dealbreaker: Style/TrailingCommaInLiteral: Enabled: false + +# would require external library +Style/IndentHeredoc: + Enabled: false