openaustralia/publicwhip

View on GitHub
app/helpers/policies_helper.rb

Summary

Maintainability
C
7 hrs
Test Coverage
C
72%

Method policy_version_sentence has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def policy_version_sentence(version)
    changes = []

    case version.event
    when "create"
Severity: Minor
Found in app/helpers/policies_helper.rb - About 1 hr 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 policy_version_sentence_text has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def policy_version_sentence_text(version)
    case version.event
    when "create"
      name = version.changeset["name"].second
      description = version.changeset["description"].second
Severity: Minor
Found in app/helpers/policies_helper.rb - About 1 hr 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 policy_version_sentence_text has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def policy_version_sentence_text(version)
    case version.event
    when "create"
      name = version.changeset["name"].second
      description = version.changeset["description"].second
Severity: Minor
Found in app/helpers/policies_helper.rb - About 1 hr to fix

    Method policy_version_sentence has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def policy_version_sentence(version)
        changes = []
    
        case version.event
        when "create"
    Severity: Minor
    Found in app/helpers/policies_helper.rb - About 1 hr to fix

      Method policy_division_version_sentence has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def policy_division_version_sentence(version)
          vote = policy_division_version_vote(version)
          division = policy_division_version_division(version)
          division_link = content_tag(:em, link_to(division.name, division_url_simple(division)))
          out = []
      Severity: Minor
      Found in app/helpers/policies_helper.rb - About 1 hr to fix

        Method randomise_people_voting_on_policy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def randomise_people_voting_on_policy(policy)
            distances = policy.policy_person_distances.currently_in_parliament.includes(:person, person: :members)
        
            # Insert people into each category
            people_category_table = {}
        Severity: Minor
        Found in app/helpers/policies_helper.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

        There are no issues that match your filters.

        Category
        Status