robertgauld/OSMExtender

View on GitHub

Showing 133 of 203 total issues

Method fetch_data has a Cognitive Complexity of 121 (exceeds 5 allowed). Consider refactoring.
Open

    def fetch_data(user_id, section_id, start:, finish:, check_earnt:, check_stock:, check_participation:, check_birthday:, check_event_attendance:, check_meeting_attendance:)
      user = User.find(user_id)
      osm_api = user.osm_api
      section = Osm::Section.get(osm_api, section_id)

Severity: Minor
Found in app/reports/planned_badge_requirements_report.rb - About 2 days 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 a Cognitive Complexity of 86 (exceeds 5 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: Minor
Found in app/reports/badge_completion_matrix_report.rb - About 1 day 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 a Cognitive Complexity of 74 (exceeds 5 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: Minor
Found in app/models/automation_task_leadership.rb - About 1 day 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 awarded_badges has a Cognitive Complexity of 69 (exceeds 5 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: Minor
Found in app/controllers/reports_controller.rb - About 1 day 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 calendar has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

  def calendar
    dates = [Osm.parse_date(@my_params[:start]), Osm.parse_date(@my_params[:finish])]
    if dates.include?(nil)
      flash[:error] = 'You failed to provide at least one of the dates.'
      redirect_back_or_to reports_path
Severity: Minor
Found in app/controllers/reports_controller.rb - About 1 day 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

File reports_controller.rb has 519 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class ReportsController < ApplicationController
  before_action :require_connected_to_osm
  before_action { @my_params = (params[params[:action]] || {}) }

  def index
Severity: Major
Found in app/controllers/reports_controller.rb - About 1 day to fix

    Method perform_task has a Cognitive Complexity of 51 (exceeds 5 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: Minor
    Found in app/models/automation_task_chief_scout_award.rb - About 7 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 a Cognitive Complexity of 43 (exceeds 5 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: Minor
    Found in app/reports/missing_badge_requirements_report.rb - About 6 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 a Cognitive Complexity of 43 (exceeds 5 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: Minor
    Found in app/models/automation_task_birthday_badge.rb - About 6 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 a Cognitive Complexity of 41 (exceeds 5 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: Minor
    Found in app/models/automation_task_first_aid.rb - About 6 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 members has 151 lines of code (exceeds 25 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: Major
    Found in app/controllers/osm_exports_controller.rb - About 6 hrs to fix

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

          def fetch_data(user_id, section_id, start:, finish:, check_earnt:, check_stock:, check_participation:, check_birthday:, check_event_attendance:, check_meeting_attendance:)
            user = User.find(user_id)
            osm_api = user.osm_api
            section = Osm::Section.get(osm_api, section_id)
      
      
      Severity: Major
      Found in app/reports/planned_badge_requirements_report.rb - About 5 hrs to fix

        Method balanced has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
        Open

          def balanced(start=SECTION_DURATION[@section.type].ago, finish=SECTION_DURATION[@section.type].from_now)
            zones = {:number => {}, :time => {}}
            methods = {:number => {}, :time => {}}
            earliest = Date.current
            latest = Date.current
        Severity: Minor
        Found in app/models/programme_review.rb - About 5 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 search_results has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
        Open

          def search_results
            if params[:selected].nil?
              flash[:error] = 'You must select some fields to search.'
              redirect_to osm_search_members_form_path(:search_for => params[:search_for]) and return
            end
        Severity: Minor
        Found in app/controllers/osm_search_members_controller.rb - About 5 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

        Class ApplicationController has 34 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class ApplicationController < ActionController::Base
          protect_from_forgery :with => :exception
          before_action :require_login
          before_action :require_gdpr_consent
          before_action :set_paper_trail_whodunnit
        Severity: Minor
        Found in app/controllers/application_controller.rb - About 4 hrs to fix

          Method perform_task has 94 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_chief_scout_award.rb - About 3 hrs to fix

            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

              Severity
              Category
              Status
              Source
              Language