BathHacked/energy-sparks

View on GitHub

Showing 151 of 266 total issues

Class ChartDataValues has 51 methods (exceeds 20 allowed). Consider refactoring.
Open

class ChartDataValues
  attr_reader :anaylsis_type, :title, :subtitle, :chart1_type, :chart1_subtype,
              :y_axis_label, :x_axis_label, :x_axis_categories, :x_max_value, :x_min_value,
              :advice_header, :advice_footer, :y2_axis_label, :y2_point_format, :y2_max, :x_axis_ranges, :annotations,
              :transformations, :allowed_operations, :drilldown_available, :parent_timescale_description,
Severity: Major
Found in app/models/chart_data_values.rb - About 7 hrs to fix

    File application_helper.rb has 449 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ApplicationHelper
      include Pagy::Frontend
    
      def nice_date_times(datetime, options = {})
        return '' if datetime.nil?
    Severity: Minor
    Found in app/helpers/application_helper.rb - About 6 hrs to fix

      Method initialize has 121 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def initialize(user)
          user ||= User.new # guest user (not logged in)
          alias_action :create, :read, :update, :destroy, to: :crud
      
          # All users can do these things
      Severity: Major
      Found in app/models/ability.rb - About 4 hrs to fix

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

            class BaseloadService < BaseService
              include AnalysableMixin
        
              def enough_data?
                baseload_service.enough_data?
        Severity: Minor
        Found in app/services/schools/advice/baseload_service.rb - About 4 hrs to fix

          File analysis.js has 334 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          "use strict";
          
          function updateDynamicTitles(titleWrapper, chartData) {
            var titleH3 = titleWrapper.find('h3');
            var titleH5 = titleWrapper.find('h5');
          Severity: Minor
          Found in app/assets/javascripts/analysis.js - About 4 hrs to fix

            Class Client has 32 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class Client
                class ApiFailure < StandardError; end
                class BadRequest < StandardError; end
                class NotFound < StandardError; end
                class NotAllowed < StandardError; end
            Severity: Minor
            Found in lib/transifex/client.rb - About 4 hrs to fix

              Class HomeController has 31 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class HomeController < ApplicationController
                include VideoHelper
                include ApplicationHelper
              
                # **** ALL ACTIONS IN THIS CONTROLLER ARE PUBLIC! ****
              Severity: Minor
              Found in app/controllers/home_controller.rb - About 3 hrs to fix

                Class AdviceBaseController has 31 methods (exceeds 20 allowed). Consider refactoring.
                Open

                    class AdviceBaseController < ApplicationController
                      include NonPublicSchools
                      include AdvicePageHelper
                      include SchoolAggregation
                      include DashboardAlerts
                Severity: Minor
                Found in app/controllers/schools/advice/advice_base_controller.rb - About 3 hrs to fix

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

                    def invalid_row_check
                      @reading_data.each_with_index do |reading, index|
                        reading_date = reading[:reading_date]
                        readings = reading[:readings]
                  
                  
                  Severity: Minor
                  Found in app/models/amr_reading_data.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 charge_types has 88 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def self.charge_types
                      {
                        standing_charge: {
                          units: [:day, :month, :quarter],
                          name: I18n.t('user_tariff_charge.standing_charge')
                  Severity: Major
                  Found in app/models/energy_tariff_charge.rb - About 3 hrs to fix

                    Method csv_report has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def csv_report(engaged_schools)
                            CSV.generate(headers: true) do |csv|
                              csv << ['School Group', 'School', 'Funder', 'Country', 'Activities', 'Actions',
                                      'Programmes', 'Target?', 'Transport survey?', 'Temperatures?', 'Audit?',
                                      'Active users', 'Last visit']
                    Severity: Minor
                    Found in app/controllers/admin/reports/engaged_schools_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

                    Class MeterCostsTableComponent has 28 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class MeterCostsTableComponent < ViewComponent::Base
                      # Monthly costs: a hash of Date (first day of month) => Costs::MeterMonth
                      # Change in costs: a hash of Date (first day of month) => change in total cost for month (£)
                      # id: HTML id of the table
                      # year_header: display year header row in table
                    Severity: Minor
                    Found in app/components/meter_costs_table_component.rb - About 3 hrs to fix

                      Function carbon has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export const carbon = ( function() {
                      
                        var local = {
                          neutral: '',
                          equivalences: '',
                      Severity: Minor
                      Found in app/javascript/transport_surveys/carbon.js - 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 initialize has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def initialize(user)
                          user ||= User.new # guest user (not logged in)
                          alias_action :create, :read, :update, :destroy, to: :crud
                      
                          # All users can do these things
                      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

                      Class LandingPagesController has 25 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class LandingPagesController < ApplicationController
                        TRUST = 'multi_academy_trust'.freeze
                        LA = 'local_authority'.freeze
                        # Needs to be aligned with values in set_org_types
                        GROUP_TYPES = [TRUST, LA].freeze
                      Severity: Minor
                      Found in app/controllers/landing_pages_controller.rb - About 2 hrs to fix

                        Class BaseController has 25 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                          class BaseController < ApplicationController
                            include UserTypeSpecific
                            skip_before_action :authenticate_user!
                        
                            before_action :filter
                        Severity: Minor
                        Found in app/controllers/comparisons/base_controller.rb - About 2 hrs to fix

                          Function chartSuccess has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function chartSuccess(chartConfig, chartData, chart) {
                          
                            var $chartDiv = $(chart.renderTo);
                            var chartType = chartData.chart1_type;
                            var seriesData = chartData.series_data;
                          Severity: Major
                          Found in app/assets/javascripts/analysis.js - About 2 hrs to fix

                            Function fireRequestForJson has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function fireRequestForJson(mapDiv) {
                            
                              var dataUrl = '/map.json';
                              var schoolGroupId = mapDiv.data('schoolGroupId');
                            
                            
                            Severity: Major
                            Found in app/assets/javascripts/map.js - About 2 hrs to fix

                              Method value_for has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def value_for(recent_usage, formatted: true)
                                  return nil unless recent_usage
                                  case params['metric']
                                  when 'usage' then formatted ? recent_usage.usage : recent_usage.usage_text
                                  when 'co2' then formatted ? recent_usage.co2 : recent_usage.co2_text
                              Severity: Minor
                              Found in app/helpers/school_groups_helper.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

                              Class SummaryTableData has 21 methods (exceeds 20 allowed). Consider refactoring.
                              Open

                                class SummaryTableData
                                  def initialize(template_data)
                                    @template_data = template_data
                                  end
                              
                              
                              Severity: Minor
                              Found in app/classes/tables/summary_table_data.rb - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language