AyuntamientoMadrid/participacion

View on GitHub

Showing 1,085 of 1,085 total issues

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

    scenario "is not present on large screens" do
      visit admin_root_path

      expect(page).not_to have_button "Menu"
    end
Severity: Minor
Found in spec/system/admin_spec.rb and 1 other location - About 25 mins to fix
spec/system/home_spec.rb on lines 109..122

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

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

  def css_for_proposal_info_row(proposal)
    if proposal.image.present?
      if params[:selected].present?
        "small-12 medium-9 column"
      else
Severity: Minor
Found in app/helpers/proposals_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 copy_error_to_current_translation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def copy_error_to_current_translation
        return unless errors.added?(:base, :translations_too_short)

        if locales_persisted_and_marked_for_destruction.include?(I18n.locale)
          locale = I18n.locale
Severity: Minor
Found in app/models/concerns/globalizable.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 6 locations. Consider refactoring.
Open

  describe "manager?" do
    it "is false when the user is not a manager" do
      expect(subject.manager?).to be false
    end

Severity: Major
Found in spec/models/user_spec.rb and 5 other locations - About 25 mins to fix
spec/models/user_spec.rb on lines 132..140
spec/models/user_spec.rb on lines 144..152
spec/models/user_spec.rb on lines 156..164
spec/models/user_spec.rb on lines 180..188
spec/models/user_spec.rb on lines 192..200

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

    def normalized_coordinates
      if geojson.present?
        if geojson.match(/"coordinates"\s*:\s*\[\s*\[\s*\[\s*\[/)
          coordinates.reduce([], :concat).reduce([], :concat)
        elsif geojson.match(/"coordinates"\s*:\s*\[\s*\[\s*\[/)
Severity: Minor
Found in app/models/geozone.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 resource has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def resource
      if resource_model.to_s == "Budget::Investment"
        @resource ||= instance_variable_get(:@investment)
      elsif resource_model.to_s == "Legislation::Proposal"
        @resource ||= instance_variable_get(:@proposal)
Severity: Minor
Found in app/controllers/concerns/polymorphic.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 investments_filters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def investments_filters
    [
      ("winners" if finished?),
      ("selected" if publishing_prices_or_later? && !finished?),
      ("unselected" if publishing_prices_or_later?),
Severity: Minor
Found in app/models/budget.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 avatar has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def avatar
      if comment.as_administrator?
        special_avatar("avatar_admin.png", class: "admin-avatar")
      elsif comment.as_moderator?
        special_avatar("avatar_moderator.png", class: "moderator-avatar")
Severity: Minor
Found in app/components/comments/avatar_component.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 update_logs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def update_logs
    amounts_changed = false

    [:white, :null, :total].each do |amount|
      unless send("will_save_change_to_#{amount}_amount?") && send("#{amount}_amount_in_database").present?
Severity: Minor
Found in app/models/poll/recount.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 5 locations. Consider refactoring.
Open

  describe "#debate" do
    it "does not find debates that are not public" do
      allow(Debate).to receive(:public_for_api).and_return(Debate.none)
      debate = create(:debate)

Severity: Major
Found in spec/graphql/types/query_type_spec.rb and 4 other locations - About 25 mins to fix
spec/graphql/types/query_type_spec.rb on lines 299..307
spec/graphql/types/query_type_spec.rb on lines 321..329
spec/graphql/types/query_type_spec.rb on lines 368..376
spec/graphql/types/query_type_spec.rb on lines 463..471

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

  def create
    self.resource = resource_class.send_confirmation_instructions(resource_params)
    yield resource if block_given?

    if successfully_sent?(resource)
Severity: Minor
Found in app/controllers/users/confirmations_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 4 locations. Consider refactoring.
Open

    it "is shown when the valuator has visible investments assigned in the valuating phase" do
      budget = create(:budget, :valuating)
      create(:budget_investment, :visible_to_valuators, budget: budget, valuators: [valuator])

      render_inline Valuation::Budgets::RowComponent.new(budget: budget)
Severity: Minor
Found in spec/components/valuation/budgets/row_component_spec.rb and 3 other locations - About 25 mins to fix
spec/components/valuation/budgets/row_component_spec.rb on lines 93..99
spec/components/valuation/budgets/row_component_spec.rb on lines 111..117
spec/components/valuation/budgets/row_component_spec.rb on lines 120..126

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

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

    it "is invalid if draft_end_date is before draft_start_date" do
      process = build(:legislation_process, draft_start_date: Date.current,
                                            draft_end_date: Date.current - 1.day)
      expect(process).not_to be_valid
      expect(process.errors.messages[:draft_end_date])
Severity: Minor
Found in spec/models/legislation/process_spec.rb and 3 other locations - About 25 mins to fix
spec/models/legislation/process_spec.rb on lines 160..164
spec/models/legislation/process_spec.rb on lines 179..184
spec/models/legislation/process_spec.rb on lines 201..206

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

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

  describe "moderator?" do
    it "is false when the user is not a moderator" do
      expect(subject.moderator?).to be false
    end

Severity: Major
Found in spec/models/user_spec.rb and 5 other locations - About 25 mins to fix
spec/models/user_spec.rb on lines 132..140
spec/models/user_spec.rb on lines 156..164
spec/models/user_spec.rb on lines 168..176
spec/models/user_spec.rb on lines 180..188
spec/models/user_spec.rb on lines 192..200

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

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

  describe "sdg_manager?" do
    it "is false when the user is not a sdg manager" do
      expect(subject.sdg_manager?).to be false
    end

Severity: Major
Found in spec/models/user_spec.rb and 5 other locations - About 25 mins to fix
spec/models/user_spec.rb on lines 132..140
spec/models/user_spec.rb on lines 144..152
spec/models/user_spec.rb on lines 156..164
spec/models/user_spec.rb on lines 168..176
spec/models/user_spec.rb on lines 192..200

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

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

  describe "poll_officer?" do
    it "is false when the user is not a poll officer" do
      expect(subject.poll_officer?).to be false
    end

Severity: Major
Found in spec/models/user_spec.rb and 5 other locations - About 25 mins to fix
spec/models/user_spec.rb on lines 132..140
spec/models/user_spec.rb on lines 144..152
spec/models/user_spec.rb on lines 156..164
spec/models/user_spec.rb on lines 168..176
spec/models/user_spec.rb on lines 180..188

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

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

  describe "#proposal" do
    it "does not find proposals that are not public" do
      allow(Proposal).to receive(:public_for_api).and_return(Proposal.none)
      proposal = create(:proposal)

Severity: Major
Found in spec/graphql/types/query_type_spec.rb and 4 other locations - About 25 mins to fix
spec/graphql/types/query_type_spec.rb on lines 263..271
spec/graphql/types/query_type_spec.rb on lines 321..329
spec/graphql/types/query_type_spec.rb on lines 368..376
spec/graphql/types/query_type_spec.rb on lines 463..471

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

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

  describe "#proposal_notification" do
    it "does not find proposal notifications that are not public" do
      allow(Proposal).to receive(:public_for_api).and_return(Proposal.none)
      notification = create(:proposal_notification)

Severity: Major
Found in spec/graphql/types/query_type_spec.rb and 4 other locations - About 25 mins to fix
spec/graphql/types/query_type_spec.rb on lines 263..271
spec/graphql/types/query_type_spec.rb on lines 299..307
spec/graphql/types/query_type_spec.rb on lines 321..329
spec/graphql/types/query_type_spec.rb on lines 463..471

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

    def validates_translation(method, options = {})
      validates(method, options.merge(if: lambda { |resource| resource.translations.blank? }))
      if options.include?(:length)
        translation_class.instance_eval do
          validates method,
Severity: Minor
Found in app/models/concerns/globalizable.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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def call(document_type, document_number, date_of_birth, postal_code)
    return Response.new if document_number.blank? || document_type.blank?

    if Setting["feature.remote_census"].present?
      response = RemoteCensusApi.new.call(document_type, document_number, date_of_birth, postal_code)
Severity: Minor
Found in app/lib/census_caller.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

Severity
Category
Status
Source
Language