dobtco/procure-io

View on GitHub

Showing 67 of 67 total issues

Function exclusion has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      exclusion: function(element, options) {
        var lower, message, option, upper, _ref;
        message = this.presence(element, options);
        if (message) {
          if (options.allow_blank === true) {
Severity: Minor
Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

    Function uniqueness has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          uniqueness: function(element, options) {
            var form, matches, name, name_prefix, name_suffix, valid, value;
            name = element.attr('name');
            if (/_attributes\]\[\d/.test(name)) {
              matches = name.match(/^(.+_attributes\])\[\d+\](.+)$/);
    Severity: Minor
    Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

      Function length has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            length: function(element, options) {
              var CHECKS, blankOptions, check, fn, message, operator, tokenized_length, tokenizer;
              tokenizer = options.js_tokenizer || "split('')";
              tokenized_length = new Function('element', "return (element.val()." + tokenizer + " || '').length")(element);
              CHECKS = {
      Severity: Minor
      Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

        Method display_value has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def display_value
            case response_field.field_type
            when "price"
              "$#{value}"
            when "date"
        Severity: Minor
        Found in app/models/response.rb - About 1 hr to fix

          Method notification_preference_choices has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.notification_preference_choices
              {
                teams: {
                  added_to_team: [:added_to_organization_team, :added_to_vendor_team],
                  added_your_team_to_project: true
          Severity: Minor
          Found in app/models/user.rb - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                if (event_type.in?(Event.event_types.only(:your_bid_awarded, :bid_awarded).values) &&
                    data[:bid][:award_message]) ||
            
                   # Your bid is dismissed and you're allowed to see the dismissal message
                   (event_type == Event.event_types[:your_bid_dismissed] &&
            Severity: Major
            Found in app/models/event.rb - About 1 hr to fix

              Method active_page? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def active_page?(action, class_to_add = "active")
                  pieces = action.split(/\#|\?/)
                  is_active_page = true
              
                  pieces.each_with_index do |piece, index|
              Severity: Minor
              Found in app/helpers/application_helper.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

              Method save_responses has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def save_responses(responsable, response_fields)
                  response_fields.each do |response_field|
                    next unless params[:response_fields] && (response_field_params = params[:response_fields][response_field.id.to_s])
              
                    response = responsable.responses.where(response_field_id: response_field.id).first_or_initialize(user_id: current_user.id)
              Severity: Minor
              Found in app/helpers/save_responses_helper.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

              Method has_searcher has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def has_searcher(args = {})
                    send(:include, PgSearch)
              
                    if args[:starting_query]
                      define_singleton_method :searcher_starting_query do
              Severity: Minor
              Found in lib/searcher.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

              Method calculate_i18n_interpolation_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def calculate_i18n_interpolation_data
                  return_hash = {}
              
                  attrs = [
                    "user.display_name", "bid.vendor.name", "project.title", "vendor.name",
              Severity: Minor
              Found in app/models/event.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

              Method active_user_sidebar_section? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def active_user_sidebar_section?(type, obj = nil)
                  is_active_section = case type
                  when :user
                    active_page?('home#dashboard') ||
                    active_page?('notifications#index') ||
              Severity: Minor
              Found in app/helpers/application_helper.rb - About 45 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Avoid deeply nested control flow statements.
              Open

                                if ($(this).data('notLocallyUnique')) {
                                  return $(this).removeData('notLocallyUnique').data('changed', true);
                                }
              Severity: Major
              Found in app/assets/javascripts/rails.validations.js - About 45 mins to fix

                Method initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def initialize(user)
                    can :read, Project do |project|
                      project.posted_at
                    end
                
                
                Severity: Minor
                Found in app/models/ability.rb - About 45 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

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

                  def create
                    @user = user_from_params
                
                    if @user.save
                      sign_in @user
                Severity: Minor
                Found in app/controllers/users_controller.rb - About 45 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 3 locations. Consider refactoring.
                Open

                  def index
                    search_results = FormTemplate.searcher(params, starting_query: @organization.form_templates)
                
                    respond_to do |format|
                      format.html do
                Severity: Major
                Found in app/controllers/form_templates_controller.rb and 2 other locations - About 45 mins to fix
                app/controllers/organizations_controller.rb on lines 32..42
                app/controllers/teams_controller.rb on lines 10..20

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

                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 index
                    search_results = Team.searcher(params, starting_query: @organization.teams)
                
                    respond_to do |format|
                      format.html do
                Severity: Major
                Found in app/controllers/teams_controller.rb and 2 other locations - About 45 mins to fix
                app/controllers/form_templates_controller.rb on lines 8..18
                app/controllers/organizations_controller.rb on lines 32..42

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

                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 members
                    search_results = User.searcher(params, starting_query: @organization.users)
                
                    respond_to do |format|
                      format.html do
                Severity: Major
                Found in app/controllers/organizations_controller.rb and 2 other locations - About 45 mins to fix
                app/controllers/form_templates_controller.rb on lines 8..18
                app/controllers/teams_controller.rb on lines 10..20

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

                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

                    this.filter(ClientSideValidations.selectors.forms).each(function() {
                      return ClientSideValidations.enablers.form(this);
                    });
                Severity: Minor
                Found in app/assets/javascripts/rails.validations.js and 1 other location - About 35 mins to fix
                app/assets/javascripts/rails.validations.js on lines 16..18

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

                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

                    this.filter(ClientSideValidations.selectors.inputs).each(function() {
                      return ClientSideValidations.enablers.input(this);
                    });
                Severity: Minor
                Found in app/assets/javascripts/rails.validations.js and 1 other location - About 35 mins to fix
                app/assets/javascripts/rails.validations.js on lines 13..15

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

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

                  def has_additional_text?
                       # Bid is awarded and has an award message
                    if (event_type.in?(Event.event_types.only(:your_bid_awarded, :bid_awarded).values) &&
                        data[:bid][:award_message]) ||
                
                
                Severity: Minor
                Found in app/models/event.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

                Severity
                Category
                Status
                Source
                Language