AyuntamientoMadrid/transparencia

View on GitHub

Showing 58 of 58 total issues

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

      Class AssetsDeclaration has 27 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class AssetsDeclaration < ActiveRecord::Base
        include DateHelper
        include ParseDataRows
      
        scope :for_year, -> (year) { where ["declaration_date >= ? and declaration_date <= ?", Date.new(year,1,1), Date.new(year,12,31)] }
      Severity: Minor
      Found in app/models/assets_declaration.rb - About 3 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          def create
            attrs = activities_upload_params.merge(author: current_administrator,
                                                   check_for_file: true)
            @activities_upload = ActivitiesUpload.new(attrs)
        
        
        Severity: Major
        Found in app/controllers/admin/activities_uploads_controller.rb and 1 other location - About 2 hrs to fix
        app/controllers/admin/assets_uploads_controller.rb on lines 16..49

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 80.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          def create
            attrs = assets_upload_params.merge(author: current_administrator,
                                               check_for_file: true)
            @assets_upload = AssetsUpload.new(attrs)
        
        
        Severity: Major
        Found in app/controllers/admin/assets_uploads_controller.rb and 1 other location - About 2 hrs to fix
        app/controllers/admin/activities_uploads_controller.rb on lines 17..50

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 80.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Method import_row! has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def import_row!(row, _row_index)
              person_query = Person.where(personal_code: row[:n_personal])
              job_level = JOB_LEVELS.fetch(row[:tipo_de_vinculacion])
        
              if job_level == 'councillor'
        Severity: Minor
        Found in lib/excel_importers/profile.rb - About 1 hr to fix

          Method import has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def import
                declarations = Declarations.new(@path_to_file,
                                                @period,
                                                logger: @logger,
                                                sheet_name: '1.DatosPersonales')
          Severity: Minor
          Found in lib/excel_importers/assets.rb - About 1 hr to fix

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

                def headers
                  unless @headers
                    if @header_field.present?
                      sheet.each_with_index do |row, row_index|
                        if row.first == @header_field
            Severity: Minor
            Found in lib/excel_importers/base.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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            module Importers
              module Assets
                class DebtsImporter < PeriodImporter
                  def import!
                    each_row do |row|
            Severity: Major
            Found in lib/importers/assets/debts_importer.rb and 1 other location - About 1 hr to fix
            lib/importers/assets/account_deposits_importer.rb on lines 3..17

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 61.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            module Importers
              module Assets
                class AccountDepositsImporter < PeriodImporter
                  def import!
                    each_row do |row|
            Severity: Major
            Found in lib/importers/assets/account_deposits_importer.rb and 1 other location - About 1 hr to fix
            lib/importers/assets/debts_importer.rb on lines 3..17

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 61.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Method import_row! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def import_row!(row, _row_index)
                  person_query = Person.where(personal_code: row[:n_personal])
                  job_level = JOB_LEVELS.fetch(row[:tipo_de_vinculacion])
            
                  if job_level == 'councillor'
            Severity: Minor
            Found in lib/excel_importers/profile.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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                class AssetsBaseImporter < ::ExcelImporters::Base
                  def initialize(path_to_file, period, logger: nil, sheet_name: nil)
                    super(path_to_file, logger: logger, sheet_name: sheet_name)
                    @period = period
                  end
            Severity: Major
            Found in lib/excel_importers/assets.rb and 1 other location - About 1 hr to fix
            lib/excel_importers/activities.rb on lines 42..62

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                class ActivitiesBaseImporter < ::ExcelImporters::Base
                  def initialize(path_to_file, period, logger: nil, sheet_name: nil)
                    super(path_to_file, logger: logger, sheet_name: sheet_name)
                    @period = period
                  end
            Severity: Major
            Found in lib/excel_importers/activities.rb and 1 other location - About 1 hr to fix
            lib/excel_importers/assets.rb on lines 63..83

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                  def parse_languages(person, row)
                    person.profile['languages'] = []
                    person.add_language('Inglés',   row[:ingles])   if row[:ingles].present?
                    person.add_language('Francés',  row[:frances])  if row[:frances].present?
                    person.add_language('Alemán',   row[:aleman])   if row[:aleman].present?
            Severity: Major
            Found in lib/excel_importers/profile.rb and 1 other location - About 1 hr to fix
            lib/importers/profiles_importer.rb on lines 75..82

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 59.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                  def parse_languages(person, row)
                    person.profile['languages'] = []
                    person.add_language('Inglés',   row[:ingles])   if row[:ingles].present?
                    person.add_language('Francés',  row[:frances])  if row[:frances].present?
                    person.add_language('Alemán',   row[:aleman])   if row[:aleman].present?
            Severity: Major
            Found in lib/importers/profiles_importer.rb and 1 other location - About 1 hr to fix
            lib/excel_importers/profile.rb on lines 140..147

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 59.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            module Importers
              module Assets
                class VehiclesImporter < PeriodImporter
                  def import!
                    each_row do |row|
            Severity: Major
            Found in lib/importers/assets/vehicles_importer.rb and 1 other location - About 1 hr to fix
            lib/importers/activities/other_importer.rb on lines 3..17

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 58.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            module Importers
              module Activities
                class OtherImporter < PeriodImporter
                  def import!
                    each_row do |row|
            Severity: Major
            Found in lib/importers/activities/other_importer.rb and 1 other location - About 1 hr to fix
            lib/importers/assets/vehicles_importer.rb on lines 3..17

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 58.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Method import! has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def import!
                  each_row(col_sep: ",") do |row|
                    person = Person.new
                    if row[:n_personal].present?
                      person = Person.where(councillor_code: row[:n_personal]).first!
            Severity: Minor
            Found in lib/importers/profiles_importer.rb - About 1 hr to fix

              Method person_params has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def person_params
                    params.require(:person).permit(
                      :first_name, :last_name, :job_level, :area, :councillor_code, :personal_code,
                      :twitter, :facebook, :role, :secondary_role, :unit, :party_id,
                      :studies_comment, :courses_comment, :career_comment, :political_posts_comment,
              Severity: Minor
              Found in app/controllers/admin/people_controller.rb - About 1 hr to fix

                Method import! has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def import!
                      each_row do |row|
                        center              = parse_text(row[:descripcion_centro])
                        organism            = parse_text(row[:organismo])
                        contract_number     = row[:numero_contrato]
                Severity: Minor
                Found in lib/importers/contracts_importer.rb - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language