robertgauld/OSMExtender

View on GitHub

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

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

    function saveCustomSizes(csrfToken) {
      $.ajax({
        url: '/my_preferences/save_custom_sizes',
        type: 'post',
        dataType: 'json',
    Severity: Major
    Found in app/assets/javascripts/osm_details/show.js and 1 other location - About 7 hrs to fix
    app/assets/javascripts/osm_flexi_records/show.js on lines 15..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 187.

    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 saveCustomSizes(csrfToken) {
      $.ajax({
        url: '/my_preferences/save_custom_sizes',
        type: 'post',
        dataType: 'json',
    Severity: Major
    Found in app/assets/javascripts/osm_flexi_records/show.js and 1 other location - About 7 hrs to fix
    app/assets/javascripts/osm_details/show.js on lines 15..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 187.

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

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

          function drawItemChart(data, options, chart) {
            data_table = new google.visualization.DataTable();
            data_table.addColumn({
              type: 'string',
              label: 'Item'
          Severity: Major
          Found in app/assets/javascripts/statistics/automation_tasks.js and 1 other location - About 4 hrs to fix
          app/assets/javascripts/statistics/email_reminders.js on lines 127..143

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

          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

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

          function drawItemChart(data, options, chart) {
            data_table = new google.visualization.DataTable();
            data_table.addColumn({
              type: 'string',
              label: 'Item'
          Severity: Major
          Found in app/assets/javascripts/statistics/email_reminders.js and 1 other location - About 4 hrs to fix
          app/assets/javascripts/statistics/automation_tasks.js on lines 38..54

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

          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 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
            Severity
            Category
            Status
            Source
            Language