mirror of
https://github.com/inspec/inspec
synced 2024-11-26 06:30:26 +00:00
Rubocop: disable GuardClause and ClassLength (#2382)
Neither of these cops is helping us write good code, and GuardClause specifically is actually contributing to us writing sometimes-unclear code. Disabling both of these cops and removing all unnecessary disable decorators in the codebase. Signed-off-by: Adam Leff <adam@leff.co>
This commit is contained in:
parent
10cad48c65
commit
a18441f86e
31 changed files with 31 additions and 36 deletions
|
@ -38,6 +38,8 @@ Metrics/AbcSize:
|
||||||
Max: 33
|
Max: 33
|
||||||
Metrics/BlockLength:
|
Metrics/BlockLength:
|
||||||
Max: 50
|
Max: 50
|
||||||
|
Metrics/ClassLength:
|
||||||
|
Enabled: false
|
||||||
Metrics/CyclomaticComplexity:
|
Metrics/CyclomaticComplexity:
|
||||||
Max: 10
|
Max: 10
|
||||||
Metrics/PerceivedComplexity:
|
Metrics/PerceivedComplexity:
|
||||||
|
@ -60,6 +62,8 @@ Style/Encoding:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/FileName:
|
Style/FileName:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
Style/GuardClause:
|
||||||
|
Enabled: false
|
||||||
Style/IfUnlessModifier:
|
Style/IfUnlessModifier:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/MethodMissing:
|
Style/MethodMissing:
|
||||||
|
|
|
@ -90,8 +90,6 @@ module Artifact
|
||||||
|
|
||||||
SIGNED_PROFILE_SUFFIX='iaf'
|
SIGNED_PROFILE_SUFFIX='iaf'
|
||||||
SIGNED_REPORT_SUFFIX='iar'
|
SIGNED_REPORT_SUFFIX='iar'
|
||||||
|
|
||||||
# rubocop:disable Metrics/ClassLength
|
|
||||||
class CLI < Inspec::BaseCLI
|
class CLI < Inspec::BaseCLI
|
||||||
namespace 'artifact'
|
namespace 'artifact'
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Compliance
|
||||||
|
|
||||||
# API Implementation does not hold any state by itself,
|
# API Implementation does not hold any state by itself,
|
||||||
# everything will be stored in local Configuration store
|
# everything will be stored in local Configuration store
|
||||||
class API # rubocop:disable Metrics/ClassLength
|
class API
|
||||||
extend Compliance::API::Login
|
extend Compliance::API::Login
|
||||||
|
|
||||||
# return all compliance profiles available for the user
|
# return all compliance profiles available for the user
|
||||||
|
|
|
@ -6,7 +6,7 @@ require 'thor'
|
||||||
require 'erb'
|
require 'erb'
|
||||||
|
|
||||||
module Compliance
|
module Compliance
|
||||||
class ComplianceCLI < Inspec::BaseCLI # rubocop:disable Metrics/ClassLength
|
class ComplianceCLI < Inspec::BaseCLI
|
||||||
namespace 'compliance'
|
namespace 'compliance'
|
||||||
|
|
||||||
# TODO: find another solution, once https://github.com/erikhuda/thor/issues/261 is fixed
|
# TODO: find another solution, once https://github.com/erikhuda/thor/issues/261 is fixed
|
||||||
|
|
|
@ -6,7 +6,7 @@ require 'mixlib/shellout'
|
||||||
require 'tomlrb'
|
require 'tomlrb'
|
||||||
|
|
||||||
module Habitat
|
module Habitat
|
||||||
class Profile # rubocop:disable Metrics/ClassLength
|
class Profile
|
||||||
attr_reader :options, :path, :profile
|
attr_reader :options, :path, :profile
|
||||||
|
|
||||||
def self.create(path, options = {})
|
def self.create(path, options = {})
|
||||||
|
|
|
@ -8,7 +8,7 @@ require 'tempfile'
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
|
|
||||||
module Fetchers
|
module Fetchers
|
||||||
class Url < Inspec.fetcher(1) # rubocop:disable Metrics/ClassLength
|
class Url < Inspec.fetcher(1)
|
||||||
MIME_TYPES = {
|
MIME_TYPES = {
|
||||||
'application/x-zip-compressed' => '.zip',
|
'application/x-zip-compressed' => '.zip',
|
||||||
'application/zip' => '.zip',
|
'application/zip' => '.zip',
|
||||||
|
|
|
@ -7,7 +7,7 @@ require 'inspec/log'
|
||||||
require 'inspec/profile_vendor'
|
require 'inspec/profile_vendor'
|
||||||
|
|
||||||
module Inspec
|
module Inspec
|
||||||
class BaseCLI < Thor # rubocop:disable Metrics/ClassLength
|
class BaseCLI < Thor
|
||||||
def self.target_options
|
def self.target_options
|
||||||
option :target, aliases: :t, type: :string,
|
option :target, aliases: :t, type: :string,
|
||||||
desc: 'Simple targeting option using URIs, e.g. ssh://user:pass@host:port'
|
desc: 'Simple targeting option using URIs, e.g. ssh://user:pass@host:port'
|
||||||
|
|
|
@ -15,7 +15,7 @@ require 'inspec/runner_mock'
|
||||||
require 'inspec/env_printer'
|
require 'inspec/env_printer'
|
||||||
require 'inspec/schema'
|
require 'inspec/schema'
|
||||||
|
|
||||||
class Inspec::InspecCLI < Inspec::BaseCLI # rubocop:disable Metrics/ClassLength
|
class Inspec::InspecCLI < Inspec::BaseCLI
|
||||||
class_option :log_level, aliases: :l, type: :string,
|
class_option :log_level, aliases: :l, type: :string,
|
||||||
desc: 'Set the log level: info (default), debug, warn, error'
|
desc: 'Set the log level: info (default), debug, warn, error'
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ module Inspec
|
||||||
# as the basic DSL of the control files (describe, control, title,
|
# as the basic DSL of the control files (describe, control, title,
|
||||||
# etc).
|
# etc).
|
||||||
#
|
#
|
||||||
class ControlEvalContext # rubocop:disable Metrics/ClassLength
|
class ControlEvalContext
|
||||||
# Create the context for controls. This includes all components of the DSL,
|
# Create the context for controls. This includes all components of the DSL,
|
||||||
# including matchers and resources.
|
# including matchers and resources.
|
||||||
#
|
#
|
||||||
|
|
|
@ -28,7 +28,6 @@ module Inspec
|
||||||
from_content(content)
|
from_content(content)
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Style/GuardClause
|
|
||||||
def self.validate_lockfile_version!(version)
|
def self.validate_lockfile_version!(version)
|
||||||
if version < MINIMUM_SUPPORTED_VERSION
|
if version < MINIMUM_SUPPORTED_VERSION
|
||||||
raise <<~EOF
|
raise <<~EOF
|
||||||
|
@ -49,7 +48,6 @@ module Inspec
|
||||||
EOF
|
EOF
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# rubocop:enable Style/GuardClause
|
|
||||||
|
|
||||||
attr_reader :version, :deps
|
attr_reader :version, :deps
|
||||||
def initialize(lockfile_content_hash)
|
def initialize(lockfile_content_hash)
|
||||||
|
|
|
@ -14,7 +14,7 @@ module Inspec
|
||||||
# A Metadata object may be created and finalized with invalid data.
|
# A Metadata object may be created and finalized with invalid data.
|
||||||
# This allows the check CLI command to analyse the issues.
|
# This allows the check CLI command to analyse the issues.
|
||||||
# Use valid? to determine if the metadata is coherent.
|
# Use valid? to determine if the metadata is coherent.
|
||||||
class Metadata # rubocop:disable Metrics/ClassLength
|
class Metadata
|
||||||
attr_reader :ref
|
attr_reader :ref
|
||||||
attr_accessor :params, :content
|
attr_accessor :params, :content
|
||||||
def initialize(ref, logger = nil)
|
def initialize(ref, logger = nil)
|
||||||
|
|
|
@ -21,7 +21,7 @@ require 'inspec/dependencies/lockfile'
|
||||||
require 'inspec/dependencies/dependency_set'
|
require 'inspec/dependencies/dependency_set'
|
||||||
|
|
||||||
module Inspec
|
module Inspec
|
||||||
class Profile # rubocop:disable Metrics/ClassLength
|
class Profile
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
|
|
||||||
def self.resolve_target(target, cache)
|
def self.resolve_target(target, cache)
|
||||||
|
|
|
@ -11,7 +11,7 @@ require 'securerandom'
|
||||||
require 'inspec/objects/attribute'
|
require 'inspec/objects/attribute'
|
||||||
|
|
||||||
module Inspec
|
module Inspec
|
||||||
class ProfileContext # rubocop:disable Metrics/ClassLength
|
class ProfileContext
|
||||||
def self.for_profile(profile, backend, attributes)
|
def self.for_profile(profile, backend, attributes)
|
||||||
new(profile.name, backend, { 'profile' => profile,
|
new(profile.name, backend, { 'profile' => profile,
|
||||||
'attributes' => attributes,
|
'attributes' => attributes,
|
||||||
|
|
|
@ -110,7 +110,7 @@ class InspecRspecMiniJson < RSpec::Core::Formatters::JsonFormatter
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class InspecRspecJson < InspecRspecMiniJson # rubocop:disable Metrics/ClassLength
|
class InspecRspecJson < InspecRspecMiniJson
|
||||||
RSpec::Core::Formatters.register self, :stop, :dump_summary
|
RSpec::Core::Formatters.register self, :stop, :dump_summary
|
||||||
attr_writer :backend
|
attr_writer :backend
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ class InspecRspecJson < InspecRspecMiniJson # rubocop:disable Metrics/ClassLengt
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class InspecRspecCli < InspecRspecJson # rubocop:disable Metrics/ClassLength
|
class InspecRspecCli < InspecRspecJson
|
||||||
RSpec::Core::Formatters.register self, :close
|
RSpec::Core::Formatters.register self, :close
|
||||||
|
|
||||||
case RUBY_PLATFORM
|
case RUBY_PLATFORM
|
||||||
|
@ -685,7 +685,7 @@ class InspecRspecCli < InspecRspecJson # rubocop:disable Metrics/ClassLength
|
||||||
# This class wraps a control hash object to provide a useful inteface for
|
# This class wraps a control hash object to provide a useful inteface for
|
||||||
# maintaining the associated profile, ids, results, title, etc.
|
# maintaining the associated profile, ids, results, title, etc.
|
||||||
#
|
#
|
||||||
class Control # rubocop:disable Metrics/ClassLength
|
class Control
|
||||||
include Comparable
|
include Comparable
|
||||||
|
|
||||||
STATUS_TYPES = {
|
STATUS_TYPES = {
|
||||||
|
|
|
@ -8,7 +8,7 @@ require 'inspec/describe'
|
||||||
require 'inspec/expect'
|
require 'inspec/expect'
|
||||||
|
|
||||||
module Inspec
|
module Inspec
|
||||||
class Rule # rubocop:disable Metrics/ClassLength
|
class Rule
|
||||||
include ::RSpec::Matchers
|
include ::RSpec::Matchers
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -28,7 +28,7 @@ module Inspec
|
||||||
# r.run
|
# r.run
|
||||||
# ```
|
# ```
|
||||||
#
|
#
|
||||||
class Runner # rubocop:disable Metrics/ClassLength
|
class Runner
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
|
|
||||||
def_delegator :@test_collector, :report
|
def_delegator :@test_collector, :report
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
require 'json'
|
require 'json'
|
||||||
|
|
||||||
module Inspec
|
module Inspec
|
||||||
class Schema # rubocop:disable Metrics/ClassLength
|
class Schema
|
||||||
STATISTICS = {
|
STATISTICS = {
|
||||||
'type' => 'object',
|
'type' => 'object',
|
||||||
'additionalProperties' => false,
|
'additionalProperties' => false,
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Inspec
|
||||||
# A pry based shell for inspec. Given a runner (with a configured backend and
|
# A pry based shell for inspec. Given a runner (with a configured backend and
|
||||||
# all that jazz), this shell will produce a pry shell from which you can run
|
# all that jazz), this shell will produce a pry shell from which you can run
|
||||||
# inspec/ruby commands that will be run within the context of the runner.
|
# inspec/ruby commands that will be run within the context of the runner.
|
||||||
class Shell # rubocop:disable Metrics/ClassLength
|
class Shell
|
||||||
def initialize(runner)
|
def initialize(runner)
|
||||||
@runner = runner
|
@runner = runner
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
require 'utils/filter'
|
require 'utils/filter'
|
||||||
require 'utils/parser'
|
require 'utils/parser'
|
||||||
|
|
||||||
# rubocop:disable Metrics/ClassLength
|
|
||||||
module Inspec::Resources
|
module Inspec::Resources
|
||||||
class AideConf < Inspec.resource(1)
|
class AideConf < Inspec.resource(1)
|
||||||
name 'aide_conf'
|
name 'aide_conf'
|
||||||
|
|
|
@ -9,7 +9,6 @@ require 'utils/filter'
|
||||||
require 'utils/parser'
|
require 'utils/parser'
|
||||||
|
|
||||||
module Inspec::Resources
|
module Inspec::Resources
|
||||||
# rubocop:disable Metrics/ClassLength
|
|
||||||
class AuditDaemon < Inspec.resource(1)
|
class AuditDaemon < Inspec.resource(1)
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
attr_accessor :lines
|
attr_accessor :lines
|
||||||
|
|
|
@ -43,8 +43,6 @@ module Inspec::Resources
|
||||||
'Audit Daemon Rules (for auditd version < 2.3)'
|
'Audit Daemon Rules (for auditd version < 2.3)'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Metrics/ClassLength
|
|
||||||
class AuditDaemonRules < Inspec.resource(1)
|
class AuditDaemonRules < Inspec.resource(1)
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
attr_accessor :rules, :lines
|
attr_accessor :rules, :lines
|
||||||
|
|
|
@ -4,7 +4,7 @@ require 'utils/parser'
|
||||||
require 'utils/filter'
|
require 'utils/filter'
|
||||||
|
|
||||||
module Inspec::Resources
|
module Inspec::Resources
|
||||||
class Crontab < Inspec.resource(1) # rubocop:disable Metrics/ClassLength
|
class Crontab < Inspec.resource(1)
|
||||||
name 'crontab'
|
name 'crontab'
|
||||||
desc 'Use the crontab InSpec audit resource to test the contents of the crontab for a given user which contains information about scheduled tasks owned by that user.'
|
desc 'Use the crontab InSpec audit resource to test the contents of the crontab for a given user which contains information about scheduled tasks owned by that user.'
|
||||||
example "
|
example "
|
||||||
|
|
|
@ -63,7 +63,7 @@ module Inspec::Resources
|
||||||
# For compatability with Serverspec we also offer the following resouses:
|
# For compatability with Serverspec we also offer the following resouses:
|
||||||
# - docker_container
|
# - docker_container
|
||||||
# - docker_image
|
# - docker_image
|
||||||
class Docker < Inspec.resource(1) # rubocop:disable Metrics/ClassLength
|
class Docker < Inspec.resource(1)
|
||||||
name 'docker'
|
name 'docker'
|
||||||
|
|
||||||
desc "
|
desc "
|
||||||
|
|
|
@ -5,7 +5,7 @@ require 'hashie/mash'
|
||||||
require 'resources/package'
|
require 'resources/package'
|
||||||
|
|
||||||
module Inspec::Resources
|
module Inspec::Resources
|
||||||
class Elasticsearch < Inspec.resource(1) # rubocop:disable Metrics/ClassLength
|
class Elasticsearch < Inspec.resource(1)
|
||||||
name 'elasticsearch'
|
name 'elasticsearch'
|
||||||
desc "Use the Elasticsearch InSpec audit resource to test the status of nodes in
|
desc "Use the Elasticsearch InSpec audit resource to test the status of nodes in
|
||||||
an Elasticsearch cluster."
|
an Elasticsearch cluster."
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
require 'utils/simpleconfig'
|
require 'utils/simpleconfig'
|
||||||
|
|
||||||
class GrubConfig < Inspec.resource(1) # rubocop:disable Metrics/ClassLength
|
class GrubConfig < Inspec.resource(1)
|
||||||
name 'grub_conf'
|
name 'grub_conf'
|
||||||
desc 'Use the grub_conf InSpec audit resource to test the boot config of Linux systems that use Grub.'
|
desc 'Use the grub_conf InSpec audit resource to test the boot config of Linux systems that use Grub.'
|
||||||
example "
|
example "
|
||||||
|
|
|
@ -381,7 +381,7 @@ module Inspec::Resources
|
||||||
end
|
end
|
||||||
|
|
||||||
# extract port information from netstat
|
# extract port information from netstat
|
||||||
class LinuxPorts < PortsInfo # rubocop:disable Metrics/ClassLength
|
class LinuxPorts < PortsInfo
|
||||||
ALLOWED_PROTOCOLS = %w{tcp tcp6 udp udp6}.freeze
|
ALLOWED_PROTOCOLS = %w{tcp tcp6 udp udp6}.freeze
|
||||||
|
|
||||||
def info
|
def info
|
||||||
|
|
|
@ -7,7 +7,7 @@ require 'utils/filter'
|
||||||
require 'ostruct'
|
require 'ostruct'
|
||||||
|
|
||||||
module Inspec::Resources
|
module Inspec::Resources
|
||||||
class Processes < Inspec.resource(1) # rubocop:disable Metrics/ClassLength
|
class Processes < Inspec.resource(1)
|
||||||
name 'processes'
|
name 'processes'
|
||||||
desc 'Use the processes InSpec audit resource to test properties for programs that are running on the system.'
|
desc 'Use the processes InSpec audit resource to test properties for programs that are running on the system.'
|
||||||
example "
|
example "
|
||||||
|
|
|
@ -47,7 +47,7 @@ require 'json'
|
||||||
# end
|
# end
|
||||||
|
|
||||||
module Inspec::Resources
|
module Inspec::Resources
|
||||||
class RegistryKey < Inspec.resource(1) # rubocop:disable Metrics/ClassLength
|
class RegistryKey < Inspec.resource(1)
|
||||||
name 'registry_key'
|
name 'registry_key'
|
||||||
desc 'Use the registry_key InSpec audit resource to test key values in the Microsoft Windows registry.'
|
desc 'Use the registry_key InSpec audit resource to test key values in the Microsoft Windows registry.'
|
||||||
example "
|
example "
|
||||||
|
|
|
@ -68,7 +68,7 @@ module Inspec::Resources
|
||||||
# Ubuntu < 15.04 : upstart
|
# Ubuntu < 15.04 : upstart
|
||||||
#
|
#
|
||||||
# TODO: extend the logic to detect the running init system, independently of OS
|
# TODO: extend the logic to detect the running init system, independently of OS
|
||||||
class Service < Inspec.resource(1) # rubocop:disable ClassLength
|
class Service < Inspec.resource(1)
|
||||||
name 'service'
|
name 'service'
|
||||||
desc 'Use the service InSpec audit resource to test if the named service is installed, running and/or enabled.'
|
desc 'Use the service InSpec audit resource to test if the named service is installed, running and/or enabled.'
|
||||||
example "
|
example "
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
require 'hashie/mash'
|
require 'hashie/mash'
|
||||||
|
|
||||||
module Inspec::Resources
|
module Inspec::Resources
|
||||||
class Virtualization < Inspec.resource(1) # rubocop:disable Metrics/ClassLength
|
class Virtualization < Inspec.resource(1)
|
||||||
name 'virtualization'
|
name 'virtualization'
|
||||||
desc 'Use the virtualization InSpec audit resource to test the virtualization platform on which the system is running'
|
desc 'Use the virtualization InSpec audit resource to test the virtualization platform on which the system is running'
|
||||||
example "
|
example "
|
||||||
|
|
|
@ -6,7 +6,7 @@ require 'openssl'
|
||||||
require 'hashie/mash'
|
require 'hashie/mash'
|
||||||
|
|
||||||
module Inspec::Resources
|
module Inspec::Resources
|
||||||
class X509CertificateResource < Inspec.resource(1) # rubocop:disable Metrics/ClassLength
|
class X509CertificateResource < Inspec.resource(1)
|
||||||
name 'x509_certificate'
|
name 'x509_certificate'
|
||||||
desc 'Used to test x.509 certificates'
|
desc 'Used to test x.509 certificates'
|
||||||
example "
|
example "
|
||||||
|
|
Loading…
Reference in a new issue