AyuntamientoMadrid/participacion

View on GitHub

Showing 1,085 of 1,085 total issues

Function customShow has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    customShow: function(position) {
      var annotation_url;
      $(this.element).html("");
      // Clean comments section and open it
      $("#comments-box").html("");
Severity: Minor
Found in app/assets/javascripts/legislation_annotatable.js - About 1 hr to fix

    Method import_ml_proposals_tags has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def import_ml_proposals_tags
          ids = {}
          json_file = data_folder.join(MachineLearning.proposals_tags_filename)
          json_data = JSON.parse(File.read(json_file)).each(&:deep_symbolize_keys!)
          json_data.each do |attributes|
    Severity: Minor
    Found in app/models/machine_learning.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 run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def run
        begin
          export_proposals_to_json
          export_budget_investments_to_json
          export_comments_to_json
    Severity: Minor
    Found in app/models/machine_learning.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 create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        if !@process.allegations_phase.open? || @draft_version.final_version?
          render(json: {}, status: :not_found) && return
        end
    
    
    Severity: Minor
    Found in app/controllers/legislation/annotations_controller.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 check_image has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_image
          return unless image.attached?
    
          unless image.analyzed?
            attachment_changes["image"].upload
    Severity: Minor
    Found in app/models/site_customization/image.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 import_ml_investments_tags has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def import_ml_investments_tags
          ids = {}
          json_file = data_folder.join(MachineLearning.investments_tags_filename)
          json_data = JSON.parse(File.read(json_file)).each(&:deep_symbolize_keys!)
          json_data.each do |attributes|
    Severity: Minor
    Found in app/models/machine_learning.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 update has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def update
        self.resource = resource_class.find_by(confirmation_token: params[:confirmation_token])
    
        if resource.encrypted_password.blank?
          resource.assign_attributes(resource_params)
    Severity: Minor
    Found in app/controllers/users/confirmations_controller.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 admin_links has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def admin_links
          [
            (admin_link if user.administrator?),
            (moderation_link if user.administrator? || user.moderator?),
            (valuation_link if feature?(:budgets) && (user.administrator? || user.valuator?)),
    Severity: Minor
    Found in app/components/layout/admin_login_items_component.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

        it "returns selected investments" do
          budget.update!(phase: "balloting")
    
          investment1 = create(:budget_investment, :feasible, :selected,   budget: budget)
          investment2 = create(:budget_investment, :feasible, :selected,   budget: budget)
    Severity: Major
    Found in spec/models/budget/investment_spec.rb and 1 other location - About 1 hr to fix
    spec/models/budget/investment_spec.rb on lines 871..882

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

    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

        context "accents" do
          it "searches with accents" do
            debate = create(:debate, title: "difusión")
    
            results = Debate.search("difusion")
    Severity: Major
    Found in spec/models/debate_spec.rb and 1 other location - About 1 hr to fix
    spec/models/proposal_spec.rb on lines 561..574

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

    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

        context "accents" do
          it "searches with accents" do
            proposal = create(:proposal, summary: "difusión")
    
            results = Proposal.search("difusion")
    Severity: Major
    Found in spec/models/proposal_spec.rb and 1 other location - About 1 hr to fix
    spec/models/debate_spec.rb on lines 530..543

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

    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

        it "returns unselected investments" do
          budget.update!(phase: "balloting")
    
          investment1 = create(:budget_investment, :feasible, :unselected, budget: budget)
          investment2 = create(:budget_investment, :feasible, :unselected, budget: budget)
    Severity: Major
    Found in spec/models/budget/investment_spec.rb and 1 other location - About 1 hr to fix
    spec/models/budget/investment_spec.rb on lines 857..868

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

    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

    Function init_autocomplete has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        init_autocomplete: function() {
          $(".tag-autocomplete").autocomplete({
            source: function(request, response) {
              $.ajax({
                url: $(".tag-autocomplete").data("js-url"),
    Severity: Minor
    Found in app/assets/javascripts/tag_autocomplete.js - About 1 hr to fix

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

          it "finds settings by the full key name and returns its presence" do
            Setting["map.feature.f1"] = "active"
            Setting["map.feature.f2"] = true
            Setting["map.feature.f3"] = false
            Setting["map.feature.f4"] = ""
      Severity: Major
      Found in spec/helpers/settings_helper_spec.rb and 2 other locations - About 1 hr to fix
      spec/helpers/settings_helper_spec.rb on lines 16..27
      spec/helpers/settings_helper_spec.rb on lines 30..41

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

      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

          it "finds settings by the given name prefixed with 'process.' and returns its presence" do
            Setting["process.p1"] = "active"
            Setting["process.p2"] = true
            Setting["process.p3"] = false
            Setting["process.p4"] = ""
      Severity: Major
      Found in spec/helpers/settings_helper_spec.rb and 2 other locations - About 1 hr to fix
      spec/helpers/settings_helper_spec.rb on lines 16..27
      spec/helpers/settings_helper_spec.rb on lines 44..55

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

      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

        it "only returns tags with kind nil or category" do
          create(:tag, name: "Parks")
          create(:tag, :category, name: "Health")
          create(:tag, name: "Admin tag", kind: "admin")
      
      
      Severity: Major
      Found in spec/graphql/types/proposal_type_spec.rb and 1 other location - About 1 hr to fix
      spec/graphql/types/debate_type_spec.rb on lines 24..34

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

      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

        scenario "footer" do
          create(:site_customization_content_block, name: "footer", locale: "en",
                                                    body: "content for footer")
          create(:site_customization_content_block, name: "footer", locale: "es",
                                                    body: "contenido para footer")
      Severity: Major
      Found in spec/system/site_customization/content_blocks_spec.rb and 1 other location - About 1 hr to fix
      spec/system/site_customization/content_blocks_spec.rb on lines 42..58

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

      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

        describe ".force_presence_postal_code?" do
          it "return false when feature remote_census is not active" do
            Setting["feature.remote_census"] = false
      
            expect(Setting.force_presence_postal_code?).to be false
      Severity: Major
      Found in spec/models/setting_spec.rb and 1 other location - About 1 hr to fix
      spec/models/setting_spec.rb on lines 218..236

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

      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

        describe "#should_show_votes?" do
          it "returns true in selecting phase" do
            budget = create(:budget, :selecting)
            investment = create(:budget_investment, budget: budget)
      
      
      Severity: Major
      Found in spec/models/budget/investment_spec.rb and 1 other location - About 1 hr to fix
      spec/models/budget/investment_spec.rb on lines 172..185

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

      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

          it "finds settings by the given name prefixed with 'feature.' and returns its presence" do
            Setting["feature.f1"] = "active"
            Setting["feature.f2"] = true
            Setting["feature.f3"] = false
            Setting["feature.f4"] = ""
      Severity: Major
      Found in spec/helpers/settings_helper_spec.rb and 2 other locations - About 1 hr to fix
      spec/helpers/settings_helper_spec.rb on lines 30..41
      spec/helpers/settings_helper_spec.rb on lines 44..55

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

      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