Showing 203 of 203 total issues
Identical blocks of code found in 2 locations. Consider refactoring. Open
function setTextSize(to) {
$('.field_head').css('font-size', to);
$('.field_data').css('font-size', to);
$('.field_total').css('font-size', to);
$('.field_count').css('font-size', to);
- 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 89.
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
Function success
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
success: function(data, status, jqXHR) {
var addons_desired_steps = 5;
$("#section_total").html("The users of OSM Extender have access to " + data["total"] + " unique sections.");
Method perform
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def perform
noterm_emails_sent = {}
forbidden_emails_sent = {}
tasks = AutomationTask.where(active: true).order(:section_id)
count = tasks.count
- 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 event_attendance
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def self.event_attendance(user, section, events, groupings)
Rails.cache.fetch("user#{user.id}-report-event_attendance-data-#{user.id}-#{section.id}-#{events.inspect}-#{groupings.inspect}", :expires_in => 10.minutes) do
event_names = []
row_groups = {}
member_totals = {}
- 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 balanced
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
def balanced(start=SECTION_DURATION[@section.type].ago, finish=SECTION_DURATION[@section.type].from_now)
zones = {:number => {}, :time => {}}
methods = {:number => {}, :time => {}}
earliest = Date.current
latest = Date.current
Function success
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
success: function(data, status, jqXHR) {
updateStatus('Processing data.');
var number_zones_steps = (data['statistics']['zones']['number']['max_value'] > 5) ? graphGridLines(data['statistics']['zones']['number']['max_value'], 5) : data['statistics']['zones']['number']['max_value'];
var number_methods_steps = (data['statistics']['methods']['number']['max_value'] > 5) ? graphGridLines(data['statistics']['methods']['number']['max_value'], 5) : data['statistics']['methods']['number']['max_value'];
Method get_data
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def get_data
events = []
event_list = Osm::Event.get_list(user.osm_api, section_id)
event_list.reject!{ |e| e[:archived] }
event_list.each do |event|
- 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 drawChart
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
function drawChart(data, labels, options, chart, z_or_m, n_or_t) {
updateStatus('Processing chart data for ' + z_or_m + 's (by ' + n_or_t + ').');
data_table = new google.visualization.DataTable();
data_table.addColumn({
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
function getPasswordStrengthColor(strength) {
if (strength < 0.000002) {return "#ff2222" }
if (strength < 0.002) {return "#ff5555" }
if (strength < 1) {return "#ff8888" }
if (strength < 10) {return "#99ff99" }
- 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 82.
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 2 locations. Consider refactoring. Open
function getPasswordStrengthDescription(strength) {
if (strength < 0.000002) {return "Very weak" }
if (strength < 0.002) {return "Weak" }
if (strength < 1) {return "Nearly strong enough" }
if (strength < 10) {return "Strong enough" }
- 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 82.
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
Consider simplifying this complex logical expression. Open
if PlannedBadgeRequirementsReport.data_for?(
current_user.id,
current_section.id,
start: dates.first,
finish: dates.last,
Method initialize
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(user)
alias_action :destroy, :to=>:delete
alias_action :create, :read, :update, :delete, :to=>:administer
# Things everyone can do
Method perform_task
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform_task(user=self.user)
ret_val = {log_lines: log_lines=[], errors: errors=[]}
section = Osm::Section.get(user.osm_api, section_id)
if section.nil?
File application_controller.rb
has 261 lines of code (exceeds 250 allowed). Consider refactoring. Open
class ApplicationController < ActionController::Base
protect_from_forgery :with => :exception
before_action :require_login
before_action :require_gdpr_consent
before_action :set_paper_trail_whodunnit
Method planned_badge_requirements
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def planned_badge_requirements
require_section_type Constants::YOUTH_SECTIONS
require_osm_permission(:read, :programme)
require_osm_permission(:read, :events) if current_section.subscription_at_least?(:silver)
- 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 drawCharts
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
function drawCharts() {
$.ajax({
url: 'email_reminders.json',
dataType:"json",
async: false,
Similar blocks of code found in 3 locations. Consider refactoring. Open
jQuery(document).ready(function(){
$('.accordion_exports h2').click(function() {
$(this).next().toggle('slow');
return false;
}).next().hide();
- 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 79.
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
jQuery(document).ready(function(){
$('.accordion_faqs h3').click(function() {
$(this).next().toggle('slow');
return false;
}).next().hide();
- 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 79.
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
jQuery(document).ready(function(){
$('.accordion_reports h2').click(function() {
$(this).next().toggle('slow');
return false;
}).next().hide();
- 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 79.
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 perform
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def perform
noterm_emails_sent = {}
forbidden_emails_sent = {}
lists = EmailList.where(:notify_changed => true).order(:section_id)
count = lists.count
- 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"