Showing 296 of 304 total issues
Class AdviceBaseController
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class AdviceBaseController < ApplicationController
include NonPublicSchools
include AdvicePageHelper
include SchoolAggregation
include DashboardAlerts
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
- 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 carbon
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
export const carbon = ( function() {
var local = {
neutral: '',
- 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 setupLiveDataChart
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setupLiveDataChart(container, maxVal) {
var chart = Highcharts.chart(container, {
chart: {
type: 'solidgauge',
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
Function exports
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(api) {
var validEnv = ['development', 'test', 'production']
var currentEnv = api.env()
var isDevelopmentEnv = api.env('development')
var isProductionEnv = api.env('production')
Function chartSuccess
has 65 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;
Class User
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ApplicationRecord
attribute :pupil_password, EncryptedField::Type.new
belongs_to :school, optional: true
belongs_to :staff_role, optional: true
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');
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
- 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 barColumnLine
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
function barColumnLine(chartData, highchartsChart, seriesData, chartConfig) {
var subChartType = chartData.chart1_subtype;
var chartType = chartData.chart1_type;
//console.log(chartType + ': ' + subChartType);
Class SummaryTableData
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class SummaryTableData
def initialize(template_data)
@template_data = template_data
end
Class HeatingControlService
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class HeatingControlService
include AnalysableMixin
# number of days heating on in warm weather => rating
WARM_WEATHER_DAYS_RATING = {
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;
- 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 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',
- 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 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',
Similar blocks of code found in 3 locations. Consider refactoring. Open
$(".resource-download-links a").click(function() {
gtag('event', 'download-link', {
'event_label': $(this).text(),
'event_category': 'resource',
'value': $(this).parents(".resource-download-links").data("event-value")
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 76.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
$(".intervention-type-download-links a").click(function() {
gtag('event', 'download-link', {
'event_label': $(this).text(),
'event_category': 'intervention-type',
'value': $(this).parents(".intervention-type-download-links").data("event-value")
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 76.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
$(".activity-type-download-links a").click(function() {
gtag('event', 'download-link', {
'event_label': $(this).text(),
'event_category': 'activity-type',
'value': $(this).parents(".activity-type-download-links").data("event-value")
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 76.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method csv
has 51 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)