robertgauld/OSMExtender

View on GitHub

Showing 203 of 203 total issues

Consider simplifying this complex logical expression.
Open

    if params[:waiting]
      if PlannedBadgeRequirementsReport.data_for?(
        current_user.id,
        current_section.id,
        start: dates.first,
Severity: Major
Found in app/controllers/reports_controller.rb - About 40 mins to fix

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

          number_options.vAxis.maxValue = graphStepSize(data['number']['max_value'], number_desired_steps) * (number_options.vAxis.gridlines.count - 1);
    Severity: Major
    Found in app/assets/javascripts/statistics/email_reminders.js and 4 other locations - About 40 mins to fix
    app/assets/javascripts/statistics/automation_tasks.js on lines 30..30
    app/assets/javascripts/statistics/email_reminders.js on lines 49..49
    app/assets/javascripts/statistics/email_reminders.js on lines 62..62
    app/assets/javascripts/statistics/sections.js on lines 71..71

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

    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

          day_options.hAxis.maxValue = graphStepSize(data['day']['max_value'], day_desired_steps) * (day_options.hAxis.gridlines.count - 1);
    Severity: Major
    Found in app/assets/javascripts/statistics/email_reminders.js and 4 other locations - About 40 mins to fix
    app/assets/javascripts/statistics/automation_tasks.js on lines 30..30
    app/assets/javascripts/statistics/email_reminders.js on lines 32..32
    app/assets/javascripts/statistics/email_reminders.js on lines 62..62
    app/assets/javascripts/statistics/sections.js on lines 71..71

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

    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

          section_addons_options.hAxis.maxValue = graphStepSize(data['addons']['max_value'], addons_desired_steps) * (section_addons_options.hAxis.gridlines.count - 1);
    Severity: Major
    Found in app/assets/javascripts/statistics/sections.js and 4 other locations - About 40 mins to fix
    app/assets/javascripts/statistics/automation_tasks.js on lines 30..30
    app/assets/javascripts/statistics/email_reminders.js on lines 32..32
    app/assets/javascripts/statistics/email_reminders.js on lines 49..49
    app/assets/javascripts/statistics/email_reminders.js on lines 62..62

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

    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

          item_options.hAxis.maxValue = graphStepSize(data['item']['max_value'], item_desired_steps) * (item_options.hAxis.gridlines.count - 1);
    Severity: Major
    Found in app/assets/javascripts/statistics/email_reminders.js and 4 other locations - About 40 mins to fix
    app/assets/javascripts/statistics/automation_tasks.js on lines 30..30
    app/assets/javascripts/statistics/email_reminders.js on lines 32..32
    app/assets/javascripts/statistics/email_reminders.js on lines 49..49
    app/assets/javascripts/statistics/sections.js on lines 71..71

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

    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

          item_options.hAxis.maxValue = graphStepSize(data['items']['max_value'], item_desired_steps) * (item_options.hAxis.gridlines.count - 1);
    Severity: Major
    Found in app/assets/javascripts/statistics/automation_tasks.js and 4 other locations - About 40 mins to fix
    app/assets/javascripts/statistics/email_reminders.js on lines 32..32
    app/assets/javascripts/statistics/email_reminders.js on lines 49..49
    app/assets/javascripts/statistics/email_reminders.js on lines 62..62
    app/assets/javascripts/statistics/sections.js on lines 71..71

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

    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 enabled_contacts[:primary_contact]
          headers.push(
            'Primary Contact 1 - First Name',
            'Primary Contact 1 - Last Name',
            'Primary Contact 1 - Address 1',
    Severity: Minor
    Found in app/controllers/osm_exports_controller.rb and 1 other location - About 35 mins to fix
    app/controllers/osm_exports_controller.rb on lines 138..156

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

    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 enabled_contacts[:secondary_contact]
          headers.push(
            'Primary Contact 2 - First Name',
            'Primary Contact 2 - Last Name',
            'Primary Contact 2 - Address 1',
    Severity: Minor
    Found in app/controllers/osm_exports_controller.rb and 1 other location - About 35 mins to fix
    app/controllers/osm_exports_controller.rb on lines 118..136

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

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

      def self.email_announcement(id)
        announcement = find(id)
    
        # Mailgun limits us to 100 message per hour.
        # So queue 1 per minute to trikle them out in batches when the worker runs.
    Severity: Minor
    Found in app/models/announcement.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

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

      def cache
        return @cache unless @cache.nil?
        redis = Rails.cache.redis
        info = redis.info
        cache_attempts = info['keyspace_hits'].to_i + info['keyspace_misses'].to_i
    Severity: Minor
    Found in app/models/status.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

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

      def deliver_reset_password_instructions!(options={})
        config = sorcery_config
        # hammering protection
        return false if config.reset_password_time_between_emails.present? && self.send(config.reset_password_email_sent_at_attribute_name) && self.send(config.reset_password_email_sent_at_attribute_name) > config.reset_password_time_between_emails.seconds.ago.utc
        self.class.sorcery_adapter.transaction do
    Severity: Minor
    Found in app/models/user.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

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

      def text_from_log_lines(lines, level=0)
        output = ''
        bullets = "*+>-"
        lines.each do |line|
          next line if line.empty?
    Severity: Minor
    Found in app/helpers/application_helper.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

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

      def validate_each(object, attribute, value)
        value = value.to_s unless value.is_a?(String)
        if !options[:allow_blank] && value.blank?
          unless value =~ /\A[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[0-1])\Z/
            object.errors.add(attribute, :date_format, options)
    Severity: Minor
    Found in lib/date_format_validator.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

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

      def multiple_get_addresses(lists)
        lists = clean_lists(lists)
        @email_lists = current_user.email_lists.find(lists).sort{ |a, b|
          section_a = Osm::Section.get(osm_api, a.section_id)
          section_b = Osm::Section.get(osm_api, b.section_id)
    Severity: Minor
    Found in app/controllers/email_lists_controller.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

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

      def flatten_hash(hash, base_key='')
        out = {}
        hash.each do |key, value|
          key = "#{base_key}_#{key}" unless base_key.empty?
          if value.is_a?(Hash)
    Severity: Minor
    Found in app/controllers/status_controller.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

              tags_in_array(activity_details.tags, ProgrammeReview::ZONES[section.type]).each do |tag|
                zone_or_method = tag[0]
                zones[:number][date_key][zone_or_method] += 1
                zones[:time][date_key][zone_or_method] += activity_details.running_time
              end
    Severity: Minor
    Found in app/models/programme_review_balanced_cache.rb and 1 other location - About 35 mins to fix
    app/models/programme_review_balanced_cache.rb on lines 35..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 35.

    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

              tags_in_array(activity_details.tags, ProgrammeReview::METHODS[section.type]).each do |tag|
                zone_or_method = tag[0]
                methods[:number][date_key][zone_or_method] += 1
                methods[:time][date_key][zone_or_method] += activity_details.running_time
              end
    Severity: Minor
    Found in app/models/programme_review_balanced_cache.rb and 1 other location - About 35 mins to fix
    app/models/programme_review_balanced_cache.rb on lines 30..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 35.

    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 "#22ff22"
    Severity: Major
    Found in app/assets/javascripts/application/passwords.js - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return {success: false, errors: ['Could not retrieve Staged badges from OSM.']}
      Severity: Major
      Found in app/models/automation_task_chief_scout_award.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return ordinalized_date(time, '%H:%M on %A %-d %B')
        Severity: Major
        Found in app/helpers/application_helper.rb - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language