BathHacked/energy-sparks

View on GitHub

Showing 159 of 283 total issues

Method add_user_to_csv has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def add_user_to_csv(csv, school_group, school, user)
        csv << [
          school_group.name,
          school.present? ? school.name : 'N/A',
          user.name,
Severity: Minor
Found in app/controllers/admin/school_groups/users_controller.rb - About 45 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 get_benchmarks_for_latest_run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def get_benchmarks_for_latest_run(latest_school_runs, benchmarks)
      latest_school_runs.each do |benchmark_result_school_generation_run|
        school_id = benchmark_result_school_generation_run.school_id

        benchmark_result_school_generation_run.benchmark_results.pluck(result_column).each do |benchmark_result|
Severity: Minor
Found in app/services/alerts/collate_benchmark_data.rb - About 45 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 no_overlaps has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def no_overlaps
    if start_date && end_date && calendar_event_type
      overlap_types = if calendar_event_type.term_time || calendar_event_type.holiday
                        (CalendarEventType.holiday + CalendarEventType.term)
                      else
Severity: Minor
Found in app/models/calendar_event.rb - About 45 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

Function processAnalysisOperations has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function processAnalysisOperations(chartConfig, chart, operations, drilldownAvailable, parentTimescaleDescription){
  var chartContainer = $(chart.renderTo);
  var controls = $(chartContainer).parent().find('.analysis-controls');
  var anyOperations = false;
  if(controls.length){
Severity: Minor
Found in app/assets/javascripts/analysis.js - About 45 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 find_interests has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def find_interests(user, list)
    ret = {}
    items = []
    items << user.school_group_name if user.school_group_name
    items << user.staff_role.title if user.staff_role
Severity: Minor
Found in app/services/mailchimp_subscriber.rb - About 45 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 select_y_axis has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def select_y_axis
      choices = y1_axis_choices
      return nil if choices.nil?
      case @school.chart_preference.to_sym
      when :default
Severity: Minor
Found in app/services/charts/y_axis_selection_service.rb - About 45 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 create_multi_chart has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def create_multi_chart(results, names, multiplier, y_axis_label, **kwargs)
Severity: Minor
Found in app/controllers/comparisons/base_controller.rb - About 35 mins to fix

    Function processAnalysisOperations has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function processAnalysisOperations(chartConfig, chart, operations, drilldownAvailable, parentTimescaleDescription){
    Severity: Minor
    Found in app/assets/javascripts/analysis.js - About 35 mins to fix

      Method create! has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def create!(meter_id, attribute_type, input_data, reason, user)
      Severity: Minor
      Found in app/services/meters/meter_attribute_manager.rb - About 35 mins to fix

        Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def initialize(school, alert_report, alert_generation_run, alert_type, asof_date)
        Severity: Minor
        Found in app/services/alerts/alert_attributes_factory.rb - About 35 mins to fix

          Method options_from_collection_for_select_with_data has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def options_from_collection_for_select_with_data(collection, value_method, text_method, selected = nil, data = {})
          Severity: Minor
          Found in app/helpers/application_helper.rb - About 35 mins to fix

            Function setUpDatePicker has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              function setUpDatePicker(divId, inputId, maxMin, defaultDate, period) {
            Severity: Minor
            Found in app/assets/javascripts/usage_charts.js - About 35 mins to fix

              Method format_body has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def format_body(email, tags, interests, merge_fields, status = 'subscribed')
              Severity: Minor
              Found in app/services/mailchimp_api.rb - About 35 mins to fix

                Method readings has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                      def readings(mpxn, fuel_type, reading_type, start_date = nil, end_date = nil)
                Severity: Minor
                Found in lib/data_feeds/n3rgy/data_api_client.rb - About 35 mins to fix

                  Method resource_data has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def resource_data(name, slug, project_id, categories, priority)
                  Severity: Minor
                  Found in lib/transifex/client.rb - About 35 mins to fix

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

                        def show
                          framework_adapter = Alerts::FrameworkAdapter.new(
                            alert_type: @alert_type,
                            school: @school,
                            analysis_date: @page.alert.run_on,
                    Severity: Minor
                    Found in app/controllers/schools/analysis_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 update_previous_events has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def update_previous_events(calendar_event, pre_save, post_save)
                        previous_event = @calendar.terms_and_holidays.find_by(end_date: calendar_event.start_date_was - 1.day)
                        if previous_event
                          callback = calendar_event.start_date > calendar_event.start_date_was ? post_save : pre_save
                          new_event_end = calendar_event.start_date - 1.day
                    Severity: Minor
                    Found in app/services/holiday_factory.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 perform has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def perform
                          # if n3rgy dont provide us with dates, we can't load data
                          return if available_date_range.empty?
                    
                          # determine start/end dates for API request, allowing for
                    Severity: Minor
                    Found in app/services/amr/n3rgy_readings_download_and_upsert.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 convert has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def convert(val)
                            return val if val.nil? || !needs_conversion?(val)
                    
                            if [true, false].include? val
                              val.to_s
                    Severity: Minor
                    Found in app/services/alerts/adapters/analytics_adapter.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 update_following_events has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def update_following_events(calendar_event, pre_save, post_save)
                        following_event = @calendar.terms_and_holidays.find_by(start_date: calendar_event.end_date_was + 1.day)
                        if following_event
                          callback = calendar_event.end_date > calendar_event.end_date_was ? pre_save : post_save
                          new_event_start = calendar_event.end_date + 1.day
                    Severity: Minor
                    Found in app/services/holiday_factory.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

                    Severity
                    Category
                    Status
                    Source
                    Language