From 51b9a3a332e51ae716515fa496139fd335594127 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Thu, 26 Dec 2019 20:40:20 -0500 Subject: [PATCH] Rubocop "fixes" --- .rubocop.yml | 5 ++++- Rakefile | 2 ++ Vagrantfile | 2 ++ bin/dots.rb | 2 ++ bin/dotutils.rb | 3 +++ bin/rake_tasks.rb | 2 ++ puppet/production/Puppetfile | 3 ++- puppet/production/scripts/config_version.rb | 2 ++ .../site/custom_libs/lib/facter/os_release.rb | 14 ++++++++------ .../custom_libs/lib/puppet/functions/find_group.rb | 2 ++ .../custom_libs/lib/puppet/functions/find_owner.rb | 2 ++ .../lib/puppet/functions/homedir_to_user.rb | 2 ++ 12 files changed, 33 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 8ca7d19..9047799 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,4 +2,7 @@ AllCops: Exclude: - 'vendor/**/*' - 'spec/fixtures/**/*' - TargetRubyVersion: 2.0 + TargetRubyVersion: 2.5 +Style/CommentedKeyword: + Enabled: false + diff --git a/Rakefile b/Rakefile index 3e367e5..0910ef1 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rubocop/rake_task' require 'rubygems' require 'puppetlabs_spec_helper/rake_tasks' diff --git a/Vagrantfile b/Vagrantfile index 6579212..ed6b50e 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Vagrant.configure('2') do |config| config.vm.box = 'genebean/centos-7-nocm' end diff --git a/bin/dots.rb b/bin/dots.rb index f861bf8..360b5c7 100755 --- a/bin/dots.rb +++ b/bin/dots.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'open3' require 'os' require 'tty-command' diff --git a/bin/dotutils.rb b/bin/dotutils.rb index 8a337b1..0df94a7 100644 --- a/bin/dotutils.rb +++ b/bin/dotutils.rb @@ -1,5 +1,8 @@ +# frozen_string_literal: true + def existing_symlink(source, destination) return if File.readlink(destination).eql?(source) + # rubocop:disable Metrics/LineLength if @prompt.yes?("#{destination} currently points to #{File.readlink(destination)}, do you want point it at #{source}?") File.unlink(destination) diff --git a/bin/rake_tasks.rb b/bin/rake_tasks.rb index c678377..c91989d 100644 --- a/bin/rake_tasks.rb +++ b/bin/rake_tasks.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + desc 'Run dots' task :dots do ruby 'bin/dots.rb' diff --git a/puppet/production/Puppetfile b/puppet/production/Puppetfile index d079145..7662506 100644 --- a/puppet/production/Puppetfile +++ b/puppet/production/Puppetfile @@ -1,4 +1,5 @@ -# rubocop:disable Lint/UnneededDisable, Naming +# frozen_string_literal: true + forge 'http://forge.puppetlabs.com' # rubocop:disable Metrics/LineLength diff --git a/puppet/production/scripts/config_version.rb b/puppet/production/scripts/config_version.rb index 8a19a95..fb4ed1d 100755 --- a/puppet/production/scripts/config_version.rb +++ b/puppet/production/scripts/config_version.rb @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + begin require 'rugged' rescue LoadError diff --git a/puppet/production/site/custom_libs/lib/facter/os_release.rb b/puppet/production/site/custom_libs/lib/facter/os_release.rb index 1b3e883..3d9f94f 100644 --- a/puppet/production/site/custom_libs/lib/facter/os_release.rb +++ b/puppet/production/site/custom_libs/lib/facter/os_release.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Facter.add(:os_release) do confine kernel: 'Linux' @@ -7,12 +9,12 @@ Facter.add(:os_release) do os_release_hash = {} File.open(file_path, 'r') do |file| file.each_line do |line| - unless line.nil? or line.strip.length.eql? 0 - line_data = line.split('=') - key = line_data[0].downcase - value = line_data[1].strip.gsub(/(^\")|(\"$)/, '') - os_release_hash[key] = value - end + next if line.nil? || line.strip.length.eql?(0) + + line_data = line.split('=') + key = line_data[0].downcase + value = line_data[1].strip.gsub(/(^\")|(\"$)/, '') + os_release_hash[key] = value end end os_release_hash diff --git a/puppet/production/site/custom_libs/lib/puppet/functions/find_group.rb b/puppet/production/site/custom_libs/lib/puppet/functions/find_group.rb index 68e589a..60d63a9 100644 --- a/puppet/production/site/custom_libs/lib/puppet/functions/find_group.rb +++ b/puppet/production/site/custom_libs/lib/puppet/functions/find_group.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Puppet::Functions.create_function(:find_group) do dispatch :find_group do param 'String', :some_path diff --git a/puppet/production/site/custom_libs/lib/puppet/functions/find_owner.rb b/puppet/production/site/custom_libs/lib/puppet/functions/find_owner.rb index 105ce2e..8a6e1fb 100644 --- a/puppet/production/site/custom_libs/lib/puppet/functions/find_owner.rb +++ b/puppet/production/site/custom_libs/lib/puppet/functions/find_owner.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Puppet::Functions.create_function(:find_owner) do dispatch :find_owner do param 'String', :some_path diff --git a/puppet/production/site/custom_libs/lib/puppet/functions/homedir_to_user.rb b/puppet/production/site/custom_libs/lib/puppet/functions/homedir_to_user.rb index ffd485d..7de542c 100644 --- a/puppet/production/site/custom_libs/lib/puppet/functions/homedir_to_user.rb +++ b/puppet/production/site/custom_libs/lib/puppet/functions/homedir_to_user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Puppet::Functions.create_function(:homedir_to_user) do dispatch :homedir_to_user do param 'String', :some_path