AyuntamientoMadrid/transparencia

View on GitHub
app/models/person.rb

Summary

Maintainability
D
2 days
Test Coverage

Class Person has 78 methods (exceeds 20 allowed). Consider refactoring.
Open

class Person < ActiveRecord::Base
  extend FriendlyId
  friendly_id :name, use: :slugged

  include ParseDataRows
Severity: Major
Found in app/models/person.rb - About 1 day to fix

    File person.rb has 341 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'sorting_name_calculator'
    
    class Person < ActiveRecord::Base
      extend FriendlyId
      friendly_id :name, use: :slugged
    Severity: Minor
    Found in app/models/person.rb - About 4 hrs to fix

      Method add_item has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def add_item(collection, description, entity, start_year, end_year)
      Severity: Minor
      Found in app/models/person.rb - About 35 mins to fix

        Avoid too many return statements within this method.
        Open

            return 'L' if labour?
        Severity: Major
        Found in app/models/person.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

              return 'V' if spokesperson?
          Severity: Major
          Found in app/models/person.rb - About 30 mins to fix

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

              def job_level_code
                return 'C' if councillor?
                return 'D' if director?
                return 'E' if temporary_worker?
                return 'F' if public_worker?
            Severity: Minor
            Found in app/models/person.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