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){
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)
Method csv_headers
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def csv_headers
[
'School group',
'School name',
'School type',
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|
- Read upRead up
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 = []
- Read upRead up
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"];
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){
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',
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,
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]
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,
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
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
- Read upRead up
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|
- Read upRead up
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',
- Read upRead up
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,
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
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) }
- Read upRead up
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 }
- Read upRead up
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?
- Read upRead up
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"