rambler-digital-solutions/Generamba

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

Summary

Maintainability
A
50 mins
Test Coverage

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

    def self.check_all_required_dependencies_has_in_podfile(dependencies, podfile_path)
      return if !dependencies || dependencies.count == 0 || !podfile_path

      dependencies_names = []
      Pod::Podfile.from_file(Pathname.new(podfile_path)).dependencies.each do |dependency|

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

    def self.check_all_required_dependencies_has_in_podfile(dependencies, podfile_path)
      return if !dependencies || dependencies.count == 0 || !podfile_path

      dependencies_names = []
      Pod::Podfile.from_file(Pathname.new(podfile_path)).dependencies.each do |dependency|

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. [11/10]
Open

    def self.check_all_required_dependencies_has_in_cartfile(dependencies, cartfile_path)
      return if !dependencies || dependencies.count == 0 || !cartfile_path

      cartfile_string = File.read(cartfile_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.

Method check_all_required_dependencies_has_in_podfile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def self.check_all_required_dependencies_has_in_podfile(dependencies, podfile_path)
      return if !dependencies || dependencies.count == 0 || !podfile_path

      dependencies_names = []
      Pod::Podfile.from_file(Pathname.new(podfile_path)).dependencies.each do |dependency|
Severity: Minor
Found in lib/generamba/helpers/dependency_checker.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

Method check_all_required_dependencies_has_in_cartfile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def self.check_all_required_dependencies_has_in_cartfile(dependencies, cartfile_path)
      return if !dependencies || dependencies.count == 0 || !cartfile_path

      cartfile_string = File.read(cartfile_path)

Severity: Minor
Found in lib/generamba/helpers/dependency_checker.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

Line is too long. [87/80]
Open

    def self.check_all_required_dependencies_has_in_podfile(dependencies, podfile_path)

Line is too long. [90/80]
Open

        puts "[Warning] Dependencies #{not_existing_dependency} missed in Cartfile".yellow

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

      if not_existing_dependency.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

Use dependencies.count.zero? instead of dependencies.count == 0.
Open

      return if !dependencies || dependencies.count == 0 || !cartfile_path

This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

Example: EnforcedStyle: predicate (default)

# bad

foo == 0
0 > foo
bar.baz > 0

# good

foo.zero?
foo.negative?
bar.baz.positive?

Example: EnforcedStyle: comparison

# bad

foo.zero?
foo.negative?
bar.baz.positive?

# good

foo == 0
0 > foo
bar.baz > 0

Line is too long. [89/80]
Open

        puts "[Warning] Dependencies #{not_existing_dependency} missed in Podfile".yellow

Line is too long. [90/80]
Open

      Pod::Podfile.from_file(Pathname.new(podfile_path)).dependencies.each do |dependency|

Use dependencies.count.zero? instead of dependencies.count == 0.
Open

      return if !dependencies || dependencies.count == 0 || !podfile_path

This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

Example: EnforcedStyle: predicate (default)

# bad

foo == 0
0 > foo
bar.baz > 0

# good

foo.zero?
foo.negative?
bar.baz.positive?

Example: EnforcedStyle: comparison

# bad

foo.zero?
foo.negative?
bar.baz.positive?

# good

foo == 0
0 > foo
bar.baz > 0

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

      if not_existing_dependency.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

Line is too long. [89/80]
Open

    def self.check_all_required_dependencies_has_in_cartfile(dependencies, cartfile_path)

There are no issues that match your filters.

Category
Status