BathHacked/energy-sparks

View on GitHub

Showing 162 of 288 total issues

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 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 csv_headers has 37 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 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

        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/packs/transport_surveys/charts.js - About 1 hr to fix

          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

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

              def self.admin_user_export_csv
                CSV.generate do |csv|
                  csv << [
                    'School Group',
                    'School',
            Severity: Minor
            Found in app/models/user.rb - About 1 hr to fix

              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

                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 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 for_school_group has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def self.for_school_group(school_group)
                        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 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 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 admin_user_export_csv has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def self.admin_user_export_csv
                          CSV.generate do |csv|
                            csv << [
                              'School Group',
                              'School',
                      Severity: Minor
                      Found in app/models/user.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 funded_school_counts has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def self.funded_school_counts(visible: true, data_enabled: true)
                            query = <<-SQL.squish
                              SELECT funders.name, count(funded_schools.id)
                              FROM funders LEFT JOIN (
                                SELECT funders.id AS funder_id, schools.id AS id
                        Severity: Minor
                        Found in app/models/funder.rb - About 1 hr to fix

                          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 rates_attrs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def rates_attrs
                              attrs = {}
                              if flat_rate?
                                if (first_price = energy_tariff_prices.first)
                                  attrs[:flat_rate] = { rate: first_price.value.to_s, per: first_price.units.to_s }
                          Severity: Minor
                          Found in app/models/energy_tariff.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

                          Severity
                          Category
                          Status
                          Source
                          Language