joaomdmoura/sigma

View on GitHub

Showing 3 of 3 total issues

Method probability has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

  def probability(expectation)
    result       = (expectation == true) ? 'wins' : nil
    result       ||= (expectation == false) ? 'losses' : 'draws'

    exp_result   = (expectation == true) ? :we : nil
Severity: Minor
Found in lib/generators/templates/resource_model.rb - About 4 hrs 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 update_sigma has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def update_sigma(exp)
    exp_result    = (@expectation == true) ? 'win_expectation' : nil
    exp_result    ||= (@expectation == false) ? 'lost_expectation' : 'draw_expectation'
    result        = (exp == true) ? 'wins' : nil
    result        ||= (exp == false) ? 'losses' : 'draws'
Severity: Minor
Found in lib/generators/templates/resource_model.rb - About 45 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 define_match_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def define_match_data(difficult)
    @expectation          = (difficult == 0) ? 0 : difficult > 0
    @resource_probability = probability(@expectation)

    if difficult == 0 || difficult < 2.5*Sigma::SCALE/100 && difficult > 0
Severity: Minor
Found in lib/generators/templates/resource_model.rb - About 45 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