robertgauld/OSMExtender

View on GitHub

Showing 203 of 203 total issues

Method send_email has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

  def send_email(options={})
    # :only_to is an array of strings or objects with an :email_address method or nil (send to everyone).
    # :except_to is an array of strings or objects with an :email_address method or nil (send to everyone).
    # :skip_subscribed_check if true then the email will be sent even if the subscription state is not :subscribed

Severity: Minor
Found in app/models/email_reminder.rb - About 3 hrs 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 sections has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

  def self.sections
    section_ids_seen = []
    section_types = {:beavers=>0, :cubs=>0, :scouts=>0, :explorers=>0, :adults=>0, :waiting=>0}
    subscription_levels = {1=>0, 2=>0, 3=>0}
    addons = {'Badges'=>0, 'Events'=>0, 'Payments'=>0, 'Programme'=>0, 'GoCardless'=>0}
Severity: Minor
Found in app/models/statistics.rb - About 3 hrs 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 perform_task has 90 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def perform_task(user=self.user)
    ret_val = {log_lines: log_lines=[], errors: errors=[]}

    section = Osm::Section.get(user.osm_api, section_id)
    if section.nil?
Severity: Major
Found in app/models/automation_task_leadership.rb - About 3 hrs to fix

    Method get_data has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_data
        latest = configuration[:the_next_n_weeks].weeks.from_now.to_date
        earliest = Date.current
    
        api = user.osm_api
    Severity: Minor
    Found in app/models/email_reminder_item_advised_absence.rb - About 3 hrs 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 badge_stock_check has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.badge_stock_check(user, section, options)
        Rails.cache.fetch("user#{user.id}-report-badge_stock_check-data-#{options.inspect}", :expires_in => 10.minutes) do
    
          badges = []
          badges += Osm::CoreBadge.get_badges_for_section(user.osm_api, section) if options[:include_core]
    Severity: Minor
    Found in app/models/report.rb - About 3 hrs 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 fetch_data has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def fetch_data(user_id, section_id, include_core:, include_challenge:, include_staged:, include_activity:, exclude_not_started:, exclude_all_finished:)
          user = User.find(user_id)
          osm_api = user.osm_api
          section = Osm::Section.get(osm_api, section_id)
    
    
    Severity: Major
    Found in app/reports/badge_completion_matrix_report.rb - About 3 hrs to fix

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

        def initialize(user)
          alias_action :destroy, :to=>:delete
          alias_action :create, :read, :update, :delete, :to=>:administer
      
          # Things everyone can do
      Severity: Minor
      Found in app/models/ability.rb - About 3 hrs 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 22 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          user = login(params[:email_address].downcase, params[:password])
          Rails.logger.debug "SessionsController#create: user is #{user.inspect}"
      
          if user
      Severity: Minor
      Found in app/controllers/sessions_controller.rb - About 3 hrs 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 planned_badge_requirements has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def planned_badge_requirements
          require_section_type Constants::YOUTH_SECTIONS
          require_osm_permission(:read, :programme)
          require_osm_permission(:read, :events) if current_section.subscription_at_least?(:silver)
      
      
      Severity: Major
      Found in app/controllers/reports_controller.rb - About 3 hrs to fix

        Function drawCharts has 74 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function drawCharts() {
          $.ajax({
            url: 'sections.json',
            dataType:"json",
            async: false,
        Severity: Major
        Found in app/assets/javascripts/statistics/sections.js - About 2 hrs to fix

          Method awarded_badges has 74 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def awarded_badges
              require_section_type Constants::YOUTH_SECTIONS
              require_osm_permission(:read, :badge)
          
              dates = [Osm.parse_date(@my_params[:start]), Osm.parse_date(@my_params[:finish])]
          Severity: Major
          Found in app/controllers/reports_controller.rb - About 2 hrs to fix

            Method members has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

              def members
                require_osm_permission :read, :member
            
                members = Osm::Member.get_for_section(osm_api, current_section, params[:term_id])
            
            
            Severity: Minor
            Found in app/controllers/osm_exports_controller.rb - About 2 hrs 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 perform_task has 72 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def perform_task(user=self.user)
                ret_val = {log_lines: [], errors: []}
                earliest = configuration[:the_last_n_days].days.ago.to_date
                latest = configuration[:the_next_n_days].days.from_now.to_date
                birthdays = []
            Severity: Major
            Found in app/models/automation_task_birthday_badge.rb - About 2 hrs to fix

              Function drawCharts has 72 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function drawCharts() {
                updateStatus('Retreiving data.');
              
                $.ajax({
                  url: 'balanced_data',
              Severity: Major
              Found in app/assets/javascripts/programme_review/balanced.js - About 2 hrs to fix

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

                function changeColumnWidth(field, by) {
                  $('.cell_' + field).css('width', parseInt($('.cell_' + field).css('width')) + by);
                  $('#table').css('width', parseInt($('#table').css('width')) + by);
                }
                Severity: Major
                Found in app/assets/javascripts/osm_details/show.js and 1 other location - About 2 hrs to fix
                app/assets/javascripts/osm_flexi_records/show.js on lines 43..46

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

                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

                function changeColumnWidth(field, by) {
                  $('.field_' + field).css('width', parseInt($('.field_' + field).css('width')) + by);
                  $('#table').css('width', parseInt($('#table').css('width')) + by);
                }
                Severity: Major
                Found in app/assets/javascripts/osm_flexi_records/show.js and 1 other location - About 2 hrs to fix
                app/assets/javascripts/osm_details/show.js on lines 43..46

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

                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

                File osm_exports_controller.rb has 281 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                class OsmExportsController < ApplicationController
                  before_action :require_connected_to_osm
                
                  before_action {
                    params[:file_options] ||= {}
                Severity: Minor
                Found in app/controllers/osm_exports_controller.rb - About 2 hrs to fix

                  Method fetch_data has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def fetch_data(user_id, section_id, include_core:, include_activity:, include_challenge:, include_staged:)
                        user = User.find(user_id)
                        osm_api = user.osm_api
                        section = Osm::Section.get(osm_api, section_id)
                  
                  
                  Severity: Major
                  Found in app/reports/missing_badge_requirements_report.rb - About 2 hrs to fix

                    Method badge_completion_matrix has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def badge_completion_matrix
                        require_section_type Constants::YOUTH_AND_ADULT_SECTIONS
                        require_osm_permission(:read, :badge)
                        return if performed? # The above either redirected or rendered
                    
                    
                    Severity: Major
                    Found in app/controllers/reports_controller.rb - About 2 hrs to fix

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

                      function setTextSize(to) {
                        $('.field_head').css('font-size', to);
                        $('.field_data').css('font-size', to);
                        $('.field_total').css('font-size', to);
                        $('.field_count').css('font-size', to);
                      Severity: Major
                      Found in app/assets/javascripts/osm_details/show.js and 1 other location - About 2 hrs to fix
                      app/assets/javascripts/osm_flexi_records/show.js on lines 1..7

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

                      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