dobtco/procure-io

View on GitHub

Showing 67 of 67 total issues

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

  def self.add_params_to_query(query, params, args = {})
    if params[:q] && !params[:q].blank?
      query = query.full_search(params[:q])
    end

Severity: Minor
Found in app/models/form_template.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

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

  def vendor_selector(f)
    if current_user.vendors.length > 1
      f.required_label(:vendor_id) +
      f.collection_select(:vendor_id, current_user.vendors, :id, :name, selected: params[:vendor_id])
    else
Severity: Minor
Found in app/helpers/application_helper.rb and 1 other location - About 30 mins to fix
app/helpers/application_helper.rb on lines 149..155

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

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 organization_selector(f)
    if current_user.organizations.length > 1
      f.label(:organization) +
      f.collection_select(:organization_id, current_user.organizations, :id, :name, selected: params[:organization_id])
    else
Severity: Minor
Found in app/helpers/application_helper.rb and 1 other location - About 30 mins to fix
app/helpers/application_helper.rb on lines 158..164

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

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

Avoid too many return statements within this function.
Open

            return;
Severity: Major
Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

              return options.message;
    Severity: Major
    Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return options.messages[check];
      Severity: Major
      Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                  return options.messages.odd;
        Severity: Major
        Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                    return options.messages.even;
          Severity: Major
          Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

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

                respond_to do |format|
                  format.html do
                    @bootstrap_data = serialized(search_results[:results], MyProjectSerializer, meta: search_results[:meta])
                  end
            
            
            Severity: Minor
            Found in app/controllers/organization_projects_controller.rb and 1 other location - About 25 mins to fix
            app/controllers/vendor_bids_controller.rb on lines 12..19

            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

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

                respond_to do |format|
                  format.html do
                    @bootstrap_data = serialized(search_results[:results], VendorBidSerializer, meta: search_results[:meta])
                  end
            
            
            Severity: Minor
            Found in app/controllers/vendor_bids_controller.rb and 1 other location - About 25 mins to fix
            app/controllers/organization_projects_controller.rb on lines 10..17

            Duplicated Code

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

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

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

            Tuning

            This issue has a mass of 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

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

                if response_field.field_options["minlength"] && (!value || value.length < response_field.field_options["minlength"].to_i)
                  @errors << "#{response_field.label} is too short. It should be #{response_field.field_options["minlength"]} characters or more."
                end
            Severity: Minor
            Found in lib/responsable_validator.rb and 1 other location - About 25 mins to fix
            lib/responsable_validator.rb on lines 37..39

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

              def extra_user_links(opts = {})
                links = []
            
                links << link_to(I18n.t('g.sign_in'), sign_in_path) unless opts[:without] == "sign_in"
                links << link_to(I18n.t('g.sign_up'), sign_up_path) unless opts[:without] == "sign_up"
            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 transform_row has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def transform_row(row)
                transformed = {}
            
                row.each do |k, v|
                  next if v.blank?
            Severity: Minor
            Found in lib/csv_bid_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

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

                if response_field.field_options["maxlength"] && (!value || value.length > response_field.field_options["maxlength"].to_i)
                  @errors << "#{response_field.label} is too long. It should be #{response_field.field_options["maxlength"]} characters or less."
                end
            Severity: Minor
            Found in lib/responsable_validator.rb and 1 other location - About 25 mins to fix
            lib/responsable_validator.rb on lines 33..35

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

              def initialize(response_fields, responses)
                @errors = []
            
                response_fields.each do |response_field|
                  response = responses.select { |response| response.response_field_id == response_field.id}.first
            Severity: Minor
            Found in lib/responsable_validator.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 postable_after_save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def postable_after_save
                  return unless posted_at_changed?
            
                  if posted
                    after_post(self.current_user) if self.respond_to?(:after_post, true)
            Severity: Minor
            Found in lib/behaviors/postable.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 min_max_length has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def min_max_length(response_field, response, value)
                if response_field.field_options["minlength"] && (!value || value.length < response_field.field_options["minlength"].to_i)
                  @errors << "#{response_field.label} is too short. It should be #{response_field.field_options["minlength"]} characters or more."
                end
            
            
            Severity: Minor
            Found in lib/responsable_validator.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 status has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def status
                if bids_due_at && open_for_bids?
                  :open_with_due_date
            
                elsif !bids_due_at && open_for_bids?
            Severity: Minor
            Found in app/models/project.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 add_params_to_query has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.add_params_to_query(query, params, args = {})
                if !params[:q].blank?
                  query = query.full_search(params[:q])
                end
            
            
            Severity: Minor
            Found in app/models/user.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

                  elsif params[:sort] == "bids_due_at"
                    query = query.order("projects.bids_due_at #{direction}")
                  elsif params[:sort] == "updated_at" || params[:sort].blank?
                    query = query.order("COALESCE(bids.submitted_at, bids.updated_at) #{direction}") # updated_by_vendor_at
                  end
            Severity: Minor
            Found in app/models/bid.rb and 1 other location - About 25 mins to fix
            app/models/user.rb on lines 71..76

            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

            Severity
            Category
            Status
            Source
            Language