Skip to content

Commit

Permalink
Make rubocop happy
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmartian committed Jan 22, 2024
1 parent 580b987 commit 8cae619
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 26 deletions.
3 changes: 1 addition & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ inherit_gem:
- config/default.yml

AllCops:
NewCops: enable
DisplayCopNames: true

AllCops:
TargetRubyVersion: 2.6
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#frozen_string_literal: true

require "rake"
require "rspec/core/rake_task"
require_relative "rake/gem"

namespace :octofacts do
task :default => [ ":octofacts:spec:octofacts", ":octofacts:spec:octofacts_updater", ":octofacts:spec:octofacts_integration" ] do
task default: [":octofacts:spec:octofacts", ":octofacts:spec:octofacts_updater", ":octofacts:spec:octofacts_integration"] do
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/octofacts/backends/index.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require "yaml"
require "set"

Expand All @@ -7,7 +8,6 @@ module Backends
class Index < Base
attr_reader :index_path, :fixture_path, :options
attr_writer :facts
attr_accessor :nodes

def initialize(args = {})
index_path = Octofacts::Util::Config.fetch(:octofacts_index_path, args)
Expand Down
12 changes: 6 additions & 6 deletions lib/octofacts_updater/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ def nodes_for_bulk
@opts[:quick] = true

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

unless File.directory?(path)
raise Errno::ENOENT, "--path must be a directory (#{path.inspect} is not)"
Expand Down
28 changes: 14 additions & 14 deletions lib/octofacts_updater/fact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,20 @@ def set_value(new_value, name_in = nil)
end

parts = if name_in.is_a?(String)
name_in.split("::")
elsif name_in.is_a?(Array)
name_in.map do |item|
if item.is_a?(String)
item
elsif item.is_a?(Hash) && item.key?("regexp")
Regexp.new(item["regexp"])
else
raise ArgumentError, "Unable to interpret structure item: #{item.inspect}"
end
end
else
raise ArgumentError, "Unable to interpret structure: #{name_in.inspect}"
end
name_in.split("::")
elsif name_in.is_a?(Array)
name_in.map do |item|
if item.is_a?(String)
item
elsif item.is_a?(Hash) && item.key?("regexp")
Regexp.new(item["regexp"])
else
raise ArgumentError, "Unable to interpret structure item: #{item.inspect}"
end
end
else
raise ArgumentError, "Unable to interpret structure: #{name_in.inspect}"
end

set_structured_value(@value, parts, new_value)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
let(:facts) do
{
ec2: true,
ec2_metadata: { placement: { :"availability-zone" : "us-foo-1a" } },
ec2_metadata: { placement: { :"availability-zone" => "us-foo-1a" } },
gid: "root",
id: "root"
}
Expand Down
2 changes: 2 additions & 0 deletions spec/octofacts_updater/service/base_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "spec_helper"

describe OctofactsUpdater::Service::Base do
Expand Down
4 changes: 3 additions & 1 deletion spec/octofacts_updater/service/enc_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# frozen_string_literal: true

require "spec_helper"

require "ostruct"

describe OctofactsUpdater::Service::ENC do
let(:config) {{ "enc" => { "path" => "/tmp/foo.enc" }}}
let(:config) { { "enc" => { "path" => "/tmp/foo.enc" }} }

describe "#run_enc" do
it "should raise ArgumentError if no configuration for the ENC is defined" do
Expand Down
2 changes: 2 additions & 0 deletions spec/octofacts_updater/service/puppetdb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "spec_helper"

require "octocatalog-diff"
Expand Down

0 comments on commit 8cae619

Please sign in to comment.