openaustralia/publicwhip

View on GitHub
app/models/whip.rb

Summary

Maintainability
B
6 hrs
Test Coverage
C
75%

Method free_vote? has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

  def free_vote?
    # Free votes from 2006 and onwards. This list from Appendix 3 of
    # http://parlinfo.aph.gov.au/parlInfo/search/display/display.w3p;query=Id%3A%22library%2Fprspub%2FCQOS6%22
    # TODO: Do we need to restrict this to only these parties? Are these votes free for all parties?

Severity: Minor
Found in app/models/whip.rb - About 3 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 free_vote? has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def free_vote?
    # Free votes from 2006 and onwards. This list from Appendix 3 of
    # http://parlinfo.aph.gov.au/parlInfo/search/display/display.w3p;query=Id%3A%22library%2Fprspub%2FCQOS6%22
    # TODO: Do we need to restrict this to only these parties? Are these votes free for all parties?

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

    Consider simplifying this complex logical expression.
    Open

          if votes
            whip.aye_votes = votes[["aye", 0]] || 0
            whip.aye_tells = votes[["aye", 1]] || 0
            whip.no_votes = votes[["no", 0]] || 0
            whip.no_tells = votes[["no", 1]] || 0
    Severity: Major
    Found in app/models/whip.rb - About 1 hr to fix

      There are no issues that match your filters.

      Category
      Status