rambler-digital-solutions/Generamba

View on GitHub
lib/generamba/helpers/module_validator.rb

Summary

Maintainability
A
25 mins
Test Coverage

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

    def validate(code_module)
      mandatory_fields = [COMPANY_KEY,
                          PROJECT_NAME_KEY,
                          XCODEPROJ_PATH_KEY]

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 all_nil_mandatory_fields_for_target_type is too high. [20.83/15]
Open

    def all_nil_mandatory_fields_for_target_type(target_type, code_module)
      fields = []

      variable_name = "#{target_type}_targets"

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

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

    def all_nil_mandatory_fields_for_target_type(target_type, code_module)
      fields = []

      variable_name = "#{target_type}_targets"

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 all_nil_mandatory_fields_for_target_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def all_nil_mandatory_fields_for_target_type(target_type, code_module)
      fields = []

      variable_name = "#{target_type}_targets"

Severity: Minor
Found in lib/generamba/helpers/module_validator.rb - About 25 mins to fix

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

Extra empty line detected at class body beginning.
Open


    TARGET_TYPE_PROJECT = 'project'

This cops checks if empty lines around the bodies of classes match the configuration.

Example: EnforcedStyle: empty_lines

# good

class Foo

  def bar
    # ...
  end

end

Example: EnforcedStyle: emptylinesexcept_namespace

# good

class Foo
  class Bar

    # ...

  end
end

Example: EnforcedStyle: emptylinesspecial

# good
class Foo

  def bar; end

end

Example: EnforcedStyle: noemptylines (default)

# good

class Foo
  def bar
    # ...
  end
end

Line is too long. [104/80]
Open

        puts "Module is broken! *#{failure_fields}* field cannot be empty, because it is mandatory.".red

Line is too long. [90/80]
Open

      group_path_const_value = Generamba.const_get(target_type.upcase + '_GROUP_PATH_KEY')

Final newline missing.
Open

end

Line is too long. [116/80]
Open

      return [] if !code_module.project_targets && !code_module.project_file_path && !code_module.project_group_path

Extra empty line detected at class body end.
Open


  end

This cops checks if empty lines around the bodies of classes match the configuration.

Example: EnforcedStyle: empty_lines

# good

class Foo

  def bar
    # ...
  end

end

Example: EnforcedStyle: emptylinesexcept_namespace

# good

class Foo
  class Bar

    # ...

  end
end

Example: EnforcedStyle: emptylinesspecial

# good
class Foo

  def bar; end

end

Example: EnforcedStyle: noemptylines (default)

# good

class Foo
  def bar
    # ...
  end
end

Line is too long. [88/80]
Open

      file_path_const_value = Generamba.const_get(target_type.upcase + '_FILE_PATH_KEY')

Line is too long. [107/80]
Open

      return [] if !code_module.test_targets && !code_module.test_file_path && !code_module.test_group_path

Line is too long. [86/80]
Open

        targets_const_value = Generamba.const_get(target_type.upcase + '_TARGETS_KEY')

Line is too long. [84/80]
Open

        target_const_value = Generamba.const_get(target_type.upcase + '_TARGET_KEY')

Line is too long. [97/80]
Open

          puts "Module is broken! *#{field}* field cannot be empty, because it is mandatory.".red

Line is too long. [103/80]
Open

      fields.push(group_path_const_value) unless code_module.instance_variable_get("@#{variable_name}")

Line is too long. [102/80]
Open

      fields.push(file_path_const_value) unless code_module.instance_variable_get("@#{variable_name}")

Use a guard clause instead of wrapping the code inside a conditional expression.
Open

      if failure_fields.count > 0

Use a guard clause instead of wrapping the code inside a conditional expression

Example:

# bad
def test
  if something
    work
  end
end

# good
def test
  return unless something
  work
end

# also good
def test
  work if something
end

# bad
if something
  raise 'exception'
else
  ok
end

# good
raise 'exception' if something
ok

Freeze mutable objects assigned to constants.
Open

    TARGET_TYPE_PROJECT = 'project'

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Freeze mutable objects assigned to constants.
Open

    TARGET_TYPE_TEST = 'test'

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

There are no issues that match your filters.

Category
Status