Showing 34 of 34 total issues
Method has too many lines. [23/10] Open
def create(params = {})
data = {
attributes: {
'is-destroy' => params[:destroy] || false
},
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [11/10] Open
def create(params = {})
org = params.delete(:organization)
workspace = params.delete(:workspace)
data = {
attributes: params,
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [11/10] Open
def define_request(method, path, data = {}, extra_headers = {})
request_options = {
method: method,
url: uri(path),
headers: headers.merge(extra_headers)
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize(rest_client_response)
@code = rest_client_response.code
@body = parse(rest_client_response.body)
return unless @body.is_a?(Hash)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Prefer $LOAD_PATH
over $:
. Open
$:.push File.expand_path("../lib", __FILE__)
- Exclude checks
The name of this source file (terraform-enterprise.rb
) should use snake_case. Open
require 'terraform_enterprise'
- Read upRead up
- Exclude checks
This cop makes sure that Ruby source files have snake_case names. Ruby scripts (i.e. source files with a shebang in the first line) are ignored.
Example:
# bad
lib/layoutManager.rb
anything/usingCamelCase
# good
lib/layout_manager.rb
anything/using_snake_case.rake
required_ruby_version
(2.3, declared in terraform-enterprise-client.gemspec) and TargetRubyVersion
(2.1, declared in .rubocop.yml) should be equal. Open
gem.required_ruby_version = '>= 2.3.0'
- Read upRead up
- Exclude checks
Checks that required_ruby_version
of gemspec and TargetRubyVersion
of .rubocop.yml are equal.
Thereby, RuboCop to perform static analysis working on the version
required by gemspec.
Example:
# When `TargetRubyVersion` of .rubocop.yml is `2.3`.
# bad
Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 2.2.0'
end
# bad
Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 2.4.0'
end
# good
Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 2.3.0'
end
# good
Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 2.3'
end
# good
Gem::Specification.new do |spec|
spec.required_ruby_version = ['>= 2.3.0', '< 2.5.0']
end
Do not use space inside array brackets. Open
gem.authors = [ "Maciej Skierkowski" ]
- Read upRead up
- Exclude checks
Checks that brackets used for array literals have or don't have surrounding space depending on configuration.
Example: EnforcedStyle: space
# The `space` style enforces that array literals have
# surrounding space.
# bad
array = [a, b, c, d]
# good
array = [ a, b, c, d ]
Example: EnforcedStyle: no_space
# The `no_space` style enforces that array literals have
# no surrounding space.
# bad
array = [ a, b, c, d ]
# good
array = [a, b, c, d]
Example: EnforcedStyle: compact
# The `compact` style normally requires a space inside
# array brackets, with the exception that successive left
# or right brackets are collapsed together in nested arrays.
# bad
array = [ a, [ b, c ] ]
# good
array = [ a, [ b, c ]]
Line is too long. [88/80] Open
gem.summary = 'Ruby client for bunthe official Terraform Enterprise API'
- Exclude checks
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
$:.push File.expand_path("../lib", __FILE__)
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Unnecessary utf-8 encoding comment. Open
# encoding: utf-8
- Exclude checks
Final newline missing. Open
end
- Exclude checks
%q
-literals should be delimited by (
and )
. Open
gem.description = %q{ Ruby client that supports all of the Terraform Enterprise API methods. }
- Read upRead up
- Exclude checks
This cop enforces the consistent usage of %
-literal delimiters.
Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.
Example:
# Style/PercentLiteralDelimiters:
# PreferredDelimiters:
# default: '[]'
# '%i': '()'
# good
%w[alpha beta] + %i(gamma delta)
# bad
%W(alpha #{beta})
# bad
%I(alpha beta)
Final newline missing. Open
require 'terraform_enterprise'
- Exclude checks
Trailing whitespace detected. Open
gem.required_ruby_version = '>= 2.3.0'
- Exclude checks
Line is too long. [106/80] Open
gem.description = %q{ Ruby client that supports all of the Terraform Enterprise API methods. }
- Exclude checks
Final newline missing. Open
require 'terraform_enterprise'
- Exclude checks
Final newline missing. Open
require 'terraform_enterprise'
- Exclude checks
Space missing to the left of {. Open
(body['included'] || []).map{ |resource| Resource.new('data' => resource)}
- Read upRead up
- Exclude checks
Checks that block braces have or don't have a space before the opening brace depending on configuration.
Example:
# bad
foo.map{ |a|
a.bar.to_s
}
# good
foo.map { |a|
a.bar.to_s
}
Do not use spaces inside percent literal delimiters. Open
gem.require_paths = %w[ lib ]
- Read upRead up
- Exclude checks
Checks for unnecessary additional spaces inside the delimiters of %i/%w/%x literals.
Example:
# good
%i(foo bar baz)
# bad
%w( foo bar baz )
# bad
%x( ls -l )