robertgauld/OSMExtender

View on GitHub
app/controllers/reports_controller.rb

Summary

Maintainability
F
6 days
Test Coverage

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

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

          Consider simplifying this complex logical expression.
          Open

                if PlannedBadgeRequirementsReport.data_for?(
                  current_user.id,
                  current_section.id,
                  start: dates.first,
                  finish: dates.last,
          Severity: Critical
          Found in app/controllers/reports_controller.rb - About 2 hrs to fix

            Method planned_badge_requirements has a Cognitive Complexity of 17 (exceeds 5 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: Minor
            Found in app/controllers/reports_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 event_attendance has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def event_attendance
                require_section_type Constants::YOUTH_AND_ADULT_SECTIONS
                require_osm_permission(:read, :events)
                return if performed? # The above either redirected or rendered
            
            
            Severity: Minor
            Found in app/controllers/reports_controller.rb - About 1 hr to fix

              Method calendar has 46 lines of code (exceeds 25 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 hr to fix

                Method missing_badge_requirements has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def missing_badge_requirements
                    require_section_type Constants::YOUTH_SECTIONS
                    require_osm_permission(:read, :badge)
                    return if performed? # The above either redirected or rendered
                
                
                Severity: Minor
                Found in app/controllers/reports_controller.rb - About 1 hr to fix

                  Method index has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def index
                      @sections = Osm::Section.get_all(osm_api)
                  
                      if has_osm_permission?(:read, :member)
                        @groupings = get_current_section_groupings.sort do |a,b|
                  Severity: Minor
                  Found in app/controllers/reports_controller.rb - About 1 hr 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 leader_access_audit has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def leader_access_audit
                      unless @my_params[:sections].is_a?(Hash)
                        flash[:error] = 'You must select some sections to sudit'
                        redirect_to reports_path
                        return
                  Severity: Minor
                  Found in app/controllers/reports_controller.rb - About 1 hr to fix

                    Method event_attendance has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def event_attendance
                        require_section_type Constants::YOUTH_AND_ADULT_SECTIONS
                        require_osm_permission(:read, :events)
                        return if performed? # The above either redirected or rendered
                    
                    
                    Severity: Minor
                    Found in app/controllers/reports_controller.rb - About 1 hr 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 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def badge_stock_check
                        @my_params = params.require(:badge_stock_check)
                                           .permit(:include_core, :include_activity, :include_challenge, :include_staged, :hide_no_stock)
                    
                        require_section_type Constants::YOUTH_AND_ADULT_SECTIONS
                    Severity: Minor
                    Found in app/controllers/reports_controller.rb - About 1 hr to fix

                      Method badge_completion_matrix has a Cognitive Complexity of 10 (exceeds 5 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: Minor
                      Found in app/controllers/reports_controller.rb - About 1 hr 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 missing_badge_requirements has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def missing_badge_requirements
                          require_section_type Constants::YOUTH_SECTIONS
                          require_osm_permission(:read, :badge)
                          return if performed? # The above either redirected or rendered
                      
                      
                      Severity: Minor
                      Found in app/controllers/reports_controller.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

                      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

                        There are no issues that match your filters.

                        Category
                        Status