InWork/ar_lock

View on GitHub

Showing 4 of 4 total issues

Method get_lock_for has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

  def self.get_lock_for names, args = {}
    successful_if_value_matches = args[:successful_if].to_s == 'value_matches'
    successful                  = false

    if names
Severity: Minor
Found in app/models/lock.rb - About 5 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 release has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def self.release names, args = {}
    successful = false

    if name
      # If names is a single string, transorm it to an array
Severity: Minor
Found in app/models/lock.rb - About 2 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 get_lock_for has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.get_lock_for names, args = {}
    successful_if_value_matches = args[:successful_if].to_s == 'value_matches'
    successful                  = false

    if names
Severity: Minor
Found in app/models/lock.rb - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                    successful = false if lock.value != args[:value]
    Severity: Major
    Found in app/models/lock.rb - About 45 mins to fix
      Severity
      Category
      Status
      Source
      Language