AyuntamientoMadrid/transparencia

View on GitHub

Showing 58 of 58 total issues

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

  def unhide
    @person = Person.friendly.find(params[:person_id])
    unhidden_at = if person_params[:unhidden_at].present?
                    Date.parse(person_params[:unhidden_at])
                  else
Severity: Minor
Found in app/controllers/admin/people_controller.rb and 1 other location - About 40 mins to fix
app/controllers/admin/people_controller.rb on lines 59..69

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 37.

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 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

    Method each_row has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def each_row(&_block)
          sheet.each_with_index do |row, row_index|
            next if row_index <= headers_row # skip header row
            row_hash = row_to_hash(row, row_index)
            next if row_hash.values.all?(&:blank?)
    Severity: Minor
    Found in lib/excel_importers/base.rb - About 35 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

    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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            attrs = profile_upload_params.merge(author: current_administrator,
                                                check_for_file: true)
            @profile_upload = ProfileUpload.new(attrs)
        
        
        Severity: Minor
        Found in app/controllers/admin/profile_uploads_controller.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

        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

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

          def breadcrumb_person_title_link(person)
            if person.councillor?
              link_to t("people.councillors.title"), councillors_people_path
            elsif person.director?
              link_to t("people.directors.title"), directors_people_path
        Severity: Minor
        Found in app/helpers/people_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

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

            class Declarations < AssetsBaseImporter
              def import_person_row!(person, row)
                declaration = person.assets_declarations.find_or_initialize_by(period: @period)
                declaration.declaration_date = row[:fecha_de_declaracion]
                declaration.save!
        Severity: Minor
        Found in lib/excel_importers/assets.rb and 1 other location - About 25 mins to fix
        lib/excel_importers/activities.rb on lines 67..72

        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 30.

        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 sortable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def sortable(column, title = nil)
            title ||= column.titleize
            css_class = column == sort_column ? "current #{sort_direction}" : nil
            direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc"
            link_to title, {:sort => column, :direction => direction}, {:class => css_class}
        Severity: Minor
        Found in app/helpers/application_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

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

          def create
            attrs = activities_upload_params.merge(author: current_administrator,
                                                   check_for_file: true)
            @activities_upload = ActivitiesUpload.new(attrs)
        
        
        Severity: Minor
        Found in app/controllers/admin/activities_uploads_controller.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

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

          def create
            attrs = assets_upload_params.merge(author: current_administrator,
                                               check_for_file: true)
            @assets_upload = AssetsUpload.new(attrs)
        
        
        Severity: Minor
        Found in app/controllers/admin/assets_uploads_controller.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

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

            class Declarations < ActivitiesBaseImporter
              def import_person_row!(person, row)
                declaration = person.activities_declarations.find_or_initialize_by(period: @period)
                declaration.declaration_date = row[:fecha_de_declaracion]
                declaration.save!
        Severity: Minor
        Found in lib/excel_importers/activities.rb and 1 other location - About 25 mins to fix
        lib/excel_importers/assets.rb on lines 88..93

        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 30.

        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 parse_spanish_date has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def parse_spanish_date(str)
              return nil if str.blank?
              day, month, year = str.to_s.split('/')
              return nil unless day.present? && month.present? && year.present?
        
        
        Severity: Minor
        Found in lib/importers/base_importer.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

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

          def complete_values
            local_attributes = attributes.delete_if{ |k,_| ['id', 'person_id'].include? k }
            local_attributes.values.map{|val| val.is_a?(Hash) ? val.values.flatten.map(&:values) : val}.flatten
        Severity: Minor
        Found in app/models/assets_declaration.rb and 1 other location - About 25 mins to fix
        app/models/activities_declaration.rb on lines 82..84

        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 29.

        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 complete_values
            local_attributes = attributes.delete_if{ |k,_| ['id', 'person_id'].include? k }
            local_attributes.values.map{|val| val.is_a?(Hash) ? val.values.flatten.map(&:values) : val}.flatten
        Severity: Minor
        Found in app/models/activities_declaration.rb and 1 other location - About 25 mins to fix
        app/models/assets_declaration.rb on lines 105..107

        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 29.

        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

                  @updated += 1
                  logger.info I18n.t('excel_importers.profile.updating',
                                     person: person.name,
                                     reference: row[:referencia],
                                     person_profiled_at: person.profiled_at.iso8601,
        Severity: Minor
        Found in lib/excel_importers/profile.rb and 1 other location - About 15 mins to fix
        lib/excel_importers/profile.rb on lines 103..108

        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 25.

        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

                @skipped += 1
                logger.info I18n.t('excel_importers.profile.skipping',
                                   person: person.name,
                                   reference: row[:referencia],
                                   person_profiled_at: person.profiled_at.iso8601,
        Severity: Minor
        Found in lib/excel_importers/profile.rb and 1 other location - About 15 mins to fix
        lib/excel_importers/profile.rb on lines 76..81

        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 25.

        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

        Severity
        Category
        Status
        Source
        Language