rambler-digital-solutions/Generamba

View on GitHub
lib/generamba/code_generation/module_template.rb

Summary

Maintainability
A
0 mins
Test Coverage

Method has too many lines. [14/10]
Open

    def initialize(name, options = nil)
      spec_path = TemplateHelper.obtain_spec(name)

      unless options
        spec = YAML.load_file(spec_path)

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

    def initialize(name, options = nil)
      spec_path = TemplateHelper.obtain_spec(name)

      unless options
        spec = YAML.load_file(spec_path)

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


  # Represents a single Generamba module template

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

    attr_reader :template_name, :template_path, :code_files, :test_files, :dependencies

Final newline missing.
Open

end

Do not use unless with else. Rewrite these with the positive case first.
Open

      unless options
        spec = YAML.load_file(spec_path)
      else
        spec_source = IO.read(spec_path)
        spec_template = Liquid::Template.parse(spec_source)

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

        spec = YAML.load(spec_content)

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")

There are no issues that match your filters.

Category
Status