lib/generamba/code_generation/module_template.rb
Method has too many lines. [14/10] Open
Open
def initialize(name, options = nil)
spec_path = TemplateHelper.obtain_spec(name)
unless options
spec = YAML.load_file(spec_path)
- 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.
Assignment Branch Condition size for initialize is too high. [15.59/15] Open
Open
def initialize(name, options = nil)
spec_path = TemplateHelper.obtain_spec(name)
unless options
spec = YAML.load_file(spec_path)
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Extra empty line detected at module body beginning. Open
Open
# Represents a single Generamba module template
- Read upRead up
- Exclude checks
This cops checks if empty lines around the bodies of modules match the configuration.
Example: EnforcedStyle: empty_lines
# good
module Foo
def bar
# ...
end
end
Example: EnforcedStyle: emptylinesexcept_namespace
# good
module Foo
module Bar
# ...
end
end
Example: EnforcedStyle: emptylinesspecial
# good
module Foo
def bar; end
end
Example: EnforcedStyle: noemptylines (default)
# good
module Foo
def bar
# ...
end
end
Line is too long. [87/80] Open
Open
attr_reader :template_name, :template_path, :code_files, :test_files, :dependencies
- Exclude checks
Final newline missing. Open
Open
end
- Exclude checks
Do not use unless
with else
. Rewrite these with the positive case first. Open
Open
unless options
spec = YAML.load_file(spec_path)
else
spec_source = IO.read(spec_path)
spec_template = Liquid::Template.parse(spec_source)
- Read upRead up
- Exclude checks
This cop looks for unless expressions with else clauses.
Example:
# bad
unless foo_bar.nil?
# do something...
else
# do a different thing...
end
# good
if foo_bar.present?
# do something...
else
# do a different thing...
end
Prefer using YAML.safe_load
over YAML.load
. Open
Open
spec = YAML.load(spec_content)
- Read upRead up
- Exclude checks
This cop checks for the use of YAML class methods which have potential security issues leading to remote code execution when loading from an untrusted source.
Example:
# bad
YAML.load("--- foo")
# good
YAML.safe_load("--- foo")
YAML.dump("foo")