BathHacked/energy-sparks

View on GitHub

Showing 151 of 266 total issues

Method report has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def report
      report = {}
      fuel_type_report = {
        enough_data: false,
        recent_data: 'N/A',
Severity: Minor
Found in app/services/targets/school_group_targets_testing_service.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

Function chartSuccess has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

function chartSuccess(chartConfig, chartData, chart) {

  var $chartDiv = $(chart.renderTo);
  var chartType = chartData.chart1_type;
  var seriesData = chartData.series_data;
Severity: Minor
Found in app/assets/javascripts/analysis.js - 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 convert_to_date_to_x48_yield_hash has a Cognitive Complexity of 16 (exceeds 5 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 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 csv has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def csv
      CSV.generate(headers: true) do |csv|
        csv << self.class.csv_headers

        school_ids = School.active.pluck(:id) + School.archived.pluck(:id)
Severity: Major
Found in app/services/schools/funder_allocation_report_service.rb - About 2 hrs to fix

    Method report has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def report
          report = {}
          fuel_type_report = {
            enough_data: false,
            recent_data: 'N/A',
    Severity: Major
    Found in app/services/targets/school_group_targets_testing_service.rb - About 2 hrs to fix

      Function carbon has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const carbon = ( function() {
      
        var local = {
          neutral: '',
          equivalences: '',
      Severity: Minor
      Found in app/javascript/transport_surveys/carbon.js - About 1 hr to fix

        Method process has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def process
            return self if @chart.nil?
            @x_data_hash = reverse_x_data_if_required
        
            @series_data = []
        Severity: Minor
        Found in app/models/chart_data_values.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 remove_users! has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def remove_users!
            raise SchoolRemover::Error.new('Cannot remove users while school is still visible') if @school.visible?
        
            @school.transaction do
              @school.users.each do |user|
        Severity: Minor
        Found in app/services/school_remover.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 based_on_energy_use has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def based_on_energy_use(limit = NUMBER_OF_SUGGESTIONS)
              alerts = alerts_by_fuel_type
              fuel_types = alerts.keys
        
              suggestions = []
        Severity: Minor
        Found in app/services/recommendations/base.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 column_or_bar has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          def column_or_bar
            @series_data = @x_data_hash.each_with_index.map do |(data_type, data), index|
              data_type = tidy_label(data_type)
              colour = work_out_best_colour(data_type)
        
        
        Severity: Minor
        Found in app/models/chart_data_values.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 processAnalysisChartAjax has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function processAnalysisChartAjax(chartId, chartConfig, highchartsChart) {
          var chartType = chartConfig.type;
          var yAxisUnits = chartConfig.y_axis_units;
          var mpanMprn = chartConfig.mpan_mprn;
          var seriesBreakdown = chartConfig.series_breakdown;
        Severity: Minor
        Found in app/assets/javascripts/analysis.js - About 1 hr to fix

          Method series_translation_key_lookup has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def series_translation_key_lookup
              @series_translation_key_lookup ||= {
                Series::DegreeDays::DEGREEDAYS => Series::DegreeDays::DEGREEDAYS_I18N_KEY,
                Series::Temperature::TEMPERATURE => Series::Temperature::TEMPERATURE_I18N_KEY,
                Series::DayType::SCHOOLDAYCLOSED => Series::DayType::SCHOOLDAYCLOSED_I18N_KEY,
          Severity: Minor
          Found in app/models/chart_data_values.rb - About 1 hr to fix

            Method export has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def export
                  service = CategoriseSchools.new(schools: @schools)
                  CSV.generate(headers: true) do |csv|
                    csv << headers
                    service.categorise_schools.each do |fuel_type, advice_pages|
            Severity: Minor
            Found in app/services/school_groups/comparisons_csv_generator.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 processAnnotations has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function processAnnotations(loaded_annotations, chart){
              var xAxis = chart.xAxis[0];
              var xAxisCategories = xAxis.categories;
            
              var annotations = loaded_annotations.map(function(annotation){
            Severity: Minor
            Found in app/assets/javascripts/analysis.js - About 1 hr to fix

              Method csv_headers has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def csv_headers
                      [
                        'School group',
                        'School name',
                        'School type',
              Severity: Minor
              Found in app/services/schools/funder_allocation_report_service.rb - About 1 hr to fix

                Method perform has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def perform
                      transifex_load = TransifexLoad.create!(status: :running)
                      begin
                        log('Synchronising Activity Types')
                        synchronise_resources(transifex_load, ActivityType.tx_resources)
                Severity: Minor
                Found in app/services/transifex/loader.rb - About 1 hr to fix

                  Method export has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def export
                        CSV.generate(headers: true) do |csv|
                          csv << headers
                          @scored_schools.with_points.schools_with_positions.each do |position, schools|
                            schools.each do |school|
                  Severity: Minor
                  Found in app/services/school_groups/current_scores_csv_generator.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_chart has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def create_chart(results, metric_to_translation_key, multiplier, y_axis_label,
                                       column_heading_keys: 'analytics.benchmarking.configuration.column_headings',
                                       y_axis_keys: 'chart_configuration.y_axis_label_name')
                        chart_data = {}
                        schools = []
                  Severity: Minor
                  Found in app/controllers/comparisons/base_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 extract_readings has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def extract_readings(readings)
                        data = {}
                        readings.each do |reading|
                          datetime = DateTime.parse(reading['from'])
                          carbon = reading['intensity']['actual']
                  Severity: Minor
                  Found in lib/data_feeds/u_k_grid_carbon_intensity_feed.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 processAnalysisOperations has 35 lines of code (exceeds 25 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 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language