Skip to content

Commit 2cd79b8

Browse files
committed
Make rubocop happy
1 parent 580b987 commit 2cd79b8

File tree

9 files changed

+34
-27
lines changed

9 files changed

+34
-27
lines changed

.rubocop.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ inherit_gem:
33
- config/default.yml
44

55
AllCops:
6+
NewCops: enable
67
DisplayCopNames: true
7-
8-
AllCops:
98
TargetRubyVersion: 2.6

Rakefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
#frozen_string_literal: true
2+
13
require "rake"
24
require "rspec/core/rake_task"
35
require_relative "rake/gem"
46

57
namespace :octofacts do
6-
task :default => [ ":octofacts:spec:octofacts", ":octofacts:spec:octofacts_updater", ":octofacts:spec:octofacts_integration" ] do
8+
task default: [":octofacts:spec:octofacts", ":octofacts:spec:octofacts_updater", ":octofacts:spec:octofacts_integration"] do
79
end
810
end
911

lib/octofacts/backends/index.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
23
require "yaml"
34
require "set"
45

@@ -7,7 +8,6 @@ module Backends
78
class Index < Base
89
attr_reader :index_path, :fixture_path, :options
910
attr_writer :facts
10-
attr_accessor :nodes
1111

1212
def initialize(args = {})
1313
index_path = Octofacts::Util::Config.fetch(:octofacts_index_path, args)

lib/octofacts_updater/cli.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ def nodes_for_bulk
134134
@opts[:quick] = true
135135

136136
path = if opts[:path]
137-
File.expand_path(opts[:path])
138-
elsif @config.fetch("index", {})["node_path"]
139-
File.expand_path(@config.fetch("index", {})["node_path"], File.dirname(opts[:config]))
140-
else
141-
raise ArgumentError, "Must set --path, or define index:node_path to a valid directory in configuration"
142-
end
137+
File.expand_path(opts[:path])
138+
elsif @config.fetch("index", {})["node_path"]
139+
File.expand_path(@config.fetch("index", {})["node_path"], File.dirname(opts[:config]))
140+
else
141+
raise ArgumentError, "Must set --path, or define index:node_path to a valid directory in configuration"
142+
end
143143

144144
unless File.directory?(path)
145145
raise Errno::ENOENT, "--path must be a directory (#{path.inspect} is not)"

lib/octofacts_updater/fact.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,20 @@ def set_value(new_value, name_in = nil)
6666
end
6767

6868
parts = if name_in.is_a?(String)
69-
name_in.split("::")
70-
elsif name_in.is_a?(Array)
71-
name_in.map do |item|
72-
if item.is_a?(String)
73-
item
74-
elsif item.is_a?(Hash) && item.key?("regexp")
75-
Regexp.new(item["regexp"])
76-
else
77-
raise ArgumentError, "Unable to interpret structure item: #{item.inspect}"
78-
end
79-
end
80-
else
81-
raise ArgumentError, "Unable to interpret structure: #{name_in.inspect}"
82-
end
69+
name_in.split("::")
70+
elsif name_in.is_a?(Array)
71+
name_in.map do |item|
72+
if item.is_a?(String)
73+
item
74+
elsif item.is_a?(Hash) && item.key?("regexp")
75+
Regexp.new(item["regexp"])
76+
else
77+
raise ArgumentError, "Unable to interpret structure item: #{item.inspect}"
78+
end
79+
end
80+
else
81+
raise ArgumentError, "Unable to interpret structure: #{name_in.inspect}"
82+
end
8383

8484
set_structured_value(@value, parts, new_value)
8585
end

spec/integration/modules/test/spec/classes/test_one_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
let(:facts) do
99
{
1010
ec2: true,
11-
ec2_metadata: { placement: { :"availability-zone" : "us-foo-1a" } },
11+
ec2_metadata: { placement: { "availability-zone": "us-foo-1a" } },
1212
gid: "root",
1313
id: "root"
1414
}
@@ -72,7 +72,7 @@
7272
end
7373

7474
context "using straight octofacts from file with manipulation of symbol converted to hash" do
75-
let(:facts) { Octofacts.from_file("basic.yaml").replace(:"ec2_metadata::placement::availability-zone" => "us-hats-1a").facts }
75+
let(:facts) { Octofacts.from_file("basic.yaml").replace("ec2_metadata::placement::availability-zone": "us-hats-1a").facts }
7676

7777
it "should contain the file resource" do
7878
is_expected.to contain_file("/tmp/system-info.txt").with(

spec/octofacts_updater/service/base_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "spec_helper"
24

35
describe OctofactsUpdater::Service::Base do

spec/octofacts_updater/service/enc_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
# frozen_string_literal: true
2+
13
require "spec_helper"
24

35
require "ostruct"
46

57
describe OctofactsUpdater::Service::ENC do
6-
let(:config) {{ "enc" => { "path" => "/tmp/foo.enc" }}}
8+
let(:config) { { "enc" => { "path" => "/tmp/foo.enc" }} }
79

810
describe "#run_enc" do
911
it "should raise ArgumentError if no configuration for the ENC is defined" do

spec/octofacts_updater/service/puppetdb_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "spec_helper"
24

35
require "octocatalog-diff"

0 commit comments

Comments
 (0)