AyuntamientoMadrid/transparencia

View on GitHub

Showing 58 of 58 total issues

Method create has 29 lines of code (exceeds 25 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 1 hr to fix

    Method create has 29 lines of code (exceeds 25 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 1 hr to fix

      Method create has 29 lines of code (exceeds 25 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 1 hr to fix

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

              def parse_studies(person, row)
                person.profile['studies'] = []
                (1..4).each do |index|
                  col = row.index("#{index}_titulacion_oficial".to_sym)
                  person.add_study(row[col], row[col+1], row[col+2], row[col+3])
        Severity: Major
        Found in lib/importers/profiles_importer.rb and 2 other locations - About 1 hr to fix
        lib/importers/profiles_importer.rb on lines 65..72
        lib/importers/profiles_importer.rb on lines 106..113

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

        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 3 locations. Consider refactoring.
        Open

              def parse_political_posts(person, row)
                person.profile['political_posts'] = []
                (1..4).each do |index|
                  col = row.index("#{index}_cargo".to_sym)
                  person.add_political_post(row[col], row[col+1], row[col+2], row[col+3])
        Severity: Major
        Found in lib/importers/profiles_importer.rb and 2 other locations - About 1 hr to fix
        lib/importers/profiles_importer.rb on lines 55..62
        lib/importers/profiles_importer.rb on lines 65..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 51.

        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 3 locations. Consider refactoring.
        Open

              def parse_courses(person, row)
                person.profile['courses'] = []
                (1..4).each do |index|
                  col = row.index("#{index}_nombre_del_curso".to_sym)
                  person.add_course(row[col], row[col+1], row[col+2], row[col+3])
        Severity: Major
        Found in lib/importers/profiles_importer.rb and 2 other locations - About 1 hr to fix
        lib/importers/profiles_importer.rb on lines 55..62
        lib/importers/profiles_importer.rb on lines 106..113

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

        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 Public < ActivitiesBaseImporter
              def import_person_row!(person, row)
                declaration = get_declaration(person)
        
                entity     = row[:entidad]
        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 227..245

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

        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 TaxData < AssetsBaseImporter
              def import_person_row!(person, row)
                declaration = get_declaration(person)
        
                tax         = row [:impuesto]
        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 76..94

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

        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 3 locations. Consider refactoring.
        Open

              def parse_political_posts(person, row)
                person.profile['political_posts'] = []
                (1..4).each do |post_index|
                  col = index("#{post_index}_cargo".to_sym)
                  person.add_political_post(row[col], row[col+1], row[col+2], row[col+3])
        Severity: Major
        Found in lib/excel_importers/profile.rb and 2 other locations - About 1 hr to fix
        lib/excel_importers/profile.rb on lines 120..127
        lib/excel_importers/profile.rb on lines 130..137

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

        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 3 locations. Consider refactoring.
        Open

              def parse_courses(person, row)
                person.profile['courses'] = []
                (1..4).each do |course_index|
                  col = index("#{course_index}_nombre_del_curso".to_sym)
                  person.add_course(row[col], row[col+1], row[col+2], row[col+3])
        Severity: Major
        Found in lib/excel_importers/profile.rb and 2 other locations - About 1 hr to fix
        lib/excel_importers/profile.rb on lines 120..127
        lib/excel_importers/profile.rb on lines 171..178

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

        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 3 locations. Consider refactoring.
        Open

              def parse_studies(person, row)
                person.profile['studies'] = []
                (1..4).each do |studies_index|
                  col = index("#{studies_index}_titulacion_oficial".to_sym)
                  person.add_study(row[col], row[col+1], row[col+2], row[col+3])
        Severity: Major
        Found in lib/excel_importers/profile.rb and 2 other locations - About 1 hr to fix
        lib/excel_importers/profile.rb on lines 130..137
        lib/excel_importers/profile.rb on lines 171..178

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

        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 26 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/activities.rb - About 1 hr to fix

          Method add_real_estate_property has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def add_real_estate_property(kind, type, description, municipality, share, purchase_date, tax_value, notes)
          Severity: Major
          Found in app/models/assets_declaration.rb - About 1 hr to fix

            Method import! has a Cognitive Complexity of 9 (exceeds 5 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 55 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

                def add_new_activities_declaration(data, person)
                  data[:activities_declarations_attributes]['0'].delete('id')
                  person.activities_declarations.build(data[:activities_declarations_attributes]['0'])
                  declaration = person.activities_declarations.last
                  data[:activities_declarations_attributes].delete('0')
            Severity: Minor
            Found in app/controllers/admin/people_controller.rb and 1 other location - About 55 mins to fix
            app/controllers/admin/people_controller.rb on lines 133..144

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

            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 add_new_assets_declaration(data, person)
                  data[:assets_declarations_attributes]['0'].delete('id')
                  person.assets_declarations.build(data[:assets_declarations_attributes]['0'])
                  declaration = person.assets_declarations.last
                  data[:assets_declarations_attributes].delete('0')
            Severity: Minor
            Found in app/controllers/admin/people_controller.rb and 1 other location - About 55 mins to fix
            app/controllers/admin/people_controller.rb on lines 119..130

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

            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 Debts < AssetsBaseImporter
                  def import_person_row!(person, row)
                    declaration = get_declaration(person)
            
                    kind           = row[:clase]
            Severity: Minor
            Found in lib/excel_importers/assets.rb and 1 other location - About 50 mins to fix
            lib/excel_importers/assets.rb on lines 127..143

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

            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 AccountDeposits < AssetsBaseImporter
                  def import_person_row!(person, row)
                    declaration = get_declaration(person)
            
                    kind            = row[:clase]
            Severity: Minor
            Found in lib/excel_importers/assets.rb and 1 other location - About 50 mins to fix
            lib/excel_importers/assets.rb on lines 207..223

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

            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_private_activity has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def add_private_activity(kind, description, entity, position, start_date, end_date)
            Severity: Minor
            Found in app/models/activities_declaration.rb - About 45 mins to fix

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

                def hide
                  @person = Person.friendly.find(params[:person_id])
                  hidden_at = if person_params[:hidden_at].present?
                                Date.parse(person_params[:hidden_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 71..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 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

              Severity
              Category
              Status
              Source
              Language