keepcosmos/terjira

View on GitHub
lib/terjira/presenters/project_presenter.rb

Summary

Maintainability
A
25 mins
Test Coverage

Assignment Branch Condition size for redner_project_detail is too high. [32.31/20]
Open

    def redner_project_detail(project)
      head = nil
      rows = []
      rows << (pastel.blue.bold(project.key) + ' ' + project.name)
      if project.respond_to?(:description)

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

    def render_projects_summary(projects)
      return render('Nothing.') if projects.blank?
      head = %w(KEY NAME TYPE).map do |v|
        { value: v, alignment: :center }
      end
Severity: Minor
Found in lib/terjira/presenters/project_presenter.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

Parenthesize the param rows.map { |row| [row] } to make sure that the block will be associated with the rows.map method call.
Open

      table = TTY::Table.new head, rows.map { |row| [row] }

This cop checks for ambiguous block association with method when param passed without parentheses.

Example:

# bad
some_method a { |val| puts val }

Example:

# good
# With parentheses, there's no ambiguity.
some_method(a) { |val| puts val }

# good
# Operator methods require no disambiguation
foo == bar { |b| b.baz }

# good
# Lambda arguments require no disambiguation
foo = ->(bar) { bar.baz }

%w-literals should be delimited by [ and ].
Open

      head = %w(KEY NAME TYPE).map do |v|

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)

There are no issues that match your filters.

Category
Status