andyw8/techradar

View on GitHub

Showing 3 of 209 total issues

Method draw_labels has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def draw_labels(corner)
    rings = %w[Adopt Trial Assess Hold]
    if corner.in?(%i[ne nw])
      rings.reverse! if corner == :nw
      rings.each_with_index do |name, index|
Severity: Minor
Found in app/models/radar_diagram.rb - About 35 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 can? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def can?(action, resource = nil)
    case action
    when :create
      (resource == Radar && user.present?) ||
        (resource.is_a?(Blip) && resource.radar.owned_by?(user))
Severity: Minor
Found in app/models/ability.rb - About 35 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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def call
    topics.map do |name|
      name.strip!
      next if name.blank?
      next if Topic.find_by(name: name, creator: creator)
Severity: Minor
Found in app/services/add_topics.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

Severity
Category
Status
Source
Language