BathHacked/energy-sparks

View on GitHub

Showing 151 of 266 total issues

Method school_params has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def school_params
    params.require(:school).permit(
      :name,
      :activation_date,
      :school_type,
Severity: Minor
Found in app/controllers/schools_controller.rb - About 1 hr to fix

    Function chart has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const chart = ( function() {
    
      var chartId = 'transport_surveys_pie';
      var colors = ["#5cb85c", "#ff3a5b", "#fff9b2", "#ffac21", "#3bc0f0"];
    
    
    Severity: Minor
    Found in app/javascript/transport_surveys/charts.js - About 1 hr to fix

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

        def initialize(chart, chart_type, transformations: [], allowed_operations: {}, drilldown_available: false, parent_timescale_description: nil, y1_axis_choices: [])
          if chart
            @chart_type         = chart_type
            @chart              = chart
            @title              = chart[:title]
      Severity: Minor
      Found in app/models/chart_data_values.rb - About 1 hr to fix

        Method metered_solar has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.metered_solar
            query = <<-SQL.squish
              SELECT ma.id, m.id, s.id, s.name, solar.*
              FROM meter_attributes ma
              JOIN meters m ON ma.meter_id = m.id
        Severity: Minor
        Found in app/models/meter_attribute.rb - About 1 hr to fix

          Method as_chart_json has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.as_chart_json(output)
              [
                :title,
                :subtitle,
                :chart1_type,
          Severity: Minor
          Found in app/models/chart_data_values.rb - About 1 hr to fix

            Method convert_to_date_to_x48_yield_hash has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def convert_to_date_to_x48_yield_hash(start_date, end_date, datetime_to_yield_hash)
                  date_to_halfhour_yields_x48 = {}
                  missing_date_times = []
                  too_little_data_on_day = []
                  interpolator = setup_interpolation(datetime_to_yield_hash)
            Severity: Minor
            Found in lib/data_feeds/pv_live_service.rb - About 1 hr to fix

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

                def parse_benchmark(benchmark)
                  chunk = []
                  intro = []
                  keep = ''
                  benchmark.each do |fragment|
              Severity: Minor
              Found in app/services/benchmark_content_filter.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 find_consent_grants has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def find_consent_grants
                    if params[:search].present?
                      search = params[:search]
                      if search['school'].present?
                        return ConsentGrant.joins(:school).where('schools.name ILIKE ?', "%#{search['school']}%").by_date
              Severity: Minor
              Found in app/controllers/admin/consent_grants_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 funding_status has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def funding_status
                    [
                      10076,
                      100076,
                      100509,
              Severity: Minor
              Found in app/services/schools/funding_status_lookup.rb - About 1 hr to fix

                Method header_groups has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def header_groups
                      [{ label: '',
                         headers: [
                           t('analytics.benchmarking.configuration.column_headings.school'),
                           t('comparisons.column_headings.recent_data')
                Severity: Minor
                Found in app/controllers/comparisons/annual_energy_use_controller.rb - About 1 hr to fix

                  Method render_json has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def render_json
                      @chart_type ||= begin
                        params.require(:chart_type).to_sym
                      rescue => error
                        render json: { error: error, status: 400 }.to_json and return
                  Severity: Minor
                  Found in app/controllers/schools/charts_controller.rb - About 1 hr to fix

                    Method header_groups has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def header_groups(fuel: true, previous_period_unadjusted: false, holiday_name: false)
                            [
                              { label: '',
                                headers: [
                                  t('analytics.benchmarking.configuration.column_headings.school'),
                    Severity: Minor
                    Found in app/controllers/comparisons/shared/arbitrary_period_controller.rb - About 1 hr to fix

                      Method meter_details_from_row has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def meter_details_from_row(row)
                            if @config.lookup_by_serial_number
                              meter_serial_number = fetch_from_row(:meter_serial_number_index, row)&.strip
                              meter = find_meter_by_serial_number(meter_serial_number)
                              mpan_mprn = meter ? meter.mpan_mprn.to_s : nil
                      Severity: Minor
                      Found in app/services/amr/data_feed_translator.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 update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def update
                          super do |resource|
                            @allow_newsletters = allow_newletters?(resource)
                            @allow_alerts = allow_alerts?(resource)
                            @subscribe_alerts = auto_create_alert_contact?
                      Severity: Minor
                      Found in app/controllers/passwords_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 create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def create
                            user = User.find_by_email(user_params[:email])
                            if user
                              user.add_cluster_school(@school)
                              user.add_cluster_school(user.school) unless user.school.nil?
                      Severity: Minor
                      Found in app/controllers/schools/cluster_admins_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 tx_update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def tx_update(data, locale)
                          raise 'Unexpected locale' unless I18n.available_locales.include?(locale)
                          raise 'Unexpected i18n format' unless data[locale.to_s].present? && !data[locale.to_s][resource_key].nil?
                      
                          translated_attributes = self.class.mobility_attributes.map { |attr| tx_attribute_key(attr) }
                      Severity: Minor
                      Found in app/models/concerns/transifex_serialisable.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 group_by_half_hour has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def group_by_half_hour(school_data_array)
                          by_half_hour = Hash.new do |h1, day_type|
                            h1[day_type] = Hash.new do |h2, month|
                              h2[month] = Hash.new do |h3, half_hour|
                                h3[half_hour] = []
                      Severity: Minor
                      Found in app/services/calculate_average_school.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

                      Function setupAnalysisControls has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function setupAnalysisControls(chartContainer, chartConfig){
                        var controls = $(chartContainer).parent().find('.analysis-controls');
                        if(controls.length){
                          controls.find('.move_back').on('click', function(event){
                            event.preventDefault();
                      Severity: Minor
                      Found in app/assets/javascripts/analysis.js - About 1 hr to fix

                        Method for_schools has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def self.for_schools(schools)
                            query = <<-SQL.squish
                              SELECT a.school_id, a.id, cv.alert_type_rating_id, vars.average_one_year_saving_£, vars.one_year_saving_co2, vars.one_year_saving_kwh
                              FROM management_priorities mp
                              INNER JOIN alert_type_rating_content_versions cv ON mp.alert_type_rating_content_version_id = cv.id
                        Severity: Minor
                        Found in app/models/management_priority.rb - About 1 hr to fix

                          Method school_params has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def school_params
                                params.require(:school).permit(
                                  :indicated_has_solar_panels,
                                  :indicated_has_storage_heaters,
                                  :has_swimming_pool,
                          Severity: Minor
                          Found in app/controllers/schools/your_school_estates_controller.rb - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language