Showing 327 of 327 total issues
Method init_rows_and_columns
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
def init_rows_and_columns
@total = 0
@row_totals = {}
@column_totals = {}
@column_headers = {}
- 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
Class User
has 43 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :encryptable,
:recoverable, :rememberable, :trackable
Function Filter
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
jobsworth.Filter = (function ($) {
function Filter() {
this.init();
this.bind();
}
- 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 ical
has 138 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ical(mode = :personal)
if params[:id].nil? || params[:id].empty?
render :nothing => true
return
end
Function TaskTodosEditor
has 136 lines of code (exceeds 25 allowed). Consider refactoring. Open
jobsworth.tasks.TaskTodosEditor = (function ($) {
function TaskTodosEditor(options) {
this.options = options;
this.el = this.options.el;
this.initialize();
Function TaskDetailsEditor
has 127 lines of code (exceeds 25 allowed). Consider refactoring. Open
jobsworth.tasks.TaskDetailsEditor = (function ($) {
function TaskDetailsEditor(options) {
this.options = options;
this.taskId = this.options.taskId;
this.el = this.options.el;
Similar blocks of code found in 2 locations. Consider refactoring. Open
ServiceEditor.prototype.selectServiceAutoCompleteCallback = function (e, ui) {
$.post("/service_level_agreements", {
service_level_agreement: {
service_id: ui.item.id,
customer_id: this.options.customer_id
- 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 134.
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
ServiceEditor.prototype.selectCustomerAutoCompleteCallback = function (e, ui) {
$.post("/service_level_agreements", {
service_level_agreement: {
customer_id: ui.item.id,
service_id: this.options.service_id
- 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 134.
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 TaskEditor
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
jobsworth.tasks.TaskEditor = (function ($) {
function TaskEditor(options) {
this.options = options;
this.taskId = this.options.taskId;
this.el = this.options.el;
- 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
Class TasksController
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
class TasksController < ApplicationController
DEFAULT_TASK_COUNT = 5
DEFAULT_TASK_NAME = 'New Task'
before_filter :check_if_user_has_projects, :only => [:new, :create]
Method do_column
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def do_column(w, key)
@column_totals[key] += w.duration unless ['comment', '1_start', '2_end', '3_task', '4_note'].include?(key)
rkey = key_from_worklog(w, 15).to_s
row_name = name_from_worklog(w, 1)
- 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 key_from_worklog
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def key_from_worklog(w, r)
if r == 1
"#{w.customer.name} #{w.project.name} #{w.task.name} #{w.task.task_num}"
elsif r == 2
w.is_a?(Tag) ? w.id : 0
- 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 name_from_worklog
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def name_from_worklog(w, r)
if r == 1
"#{w.task.issue_num} <a href=\"/tasks/view/#{w.task.task_num}\">#{ERB::Util.h w.task.name}</a> <br /><small>#{ERB::Util.h w.task.full_name}</small>".html_safe
elsif r == 2
w.is_a?(Tag) ? "#{w.name}" : I18n.t('worklog_reports.status.none')
- 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
Class TaskFilter
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
class TaskFilter < ActiveRecord::Base
# column `name` is of type `VARCHAR(255)`.
# Note that MySQL 5.x+ and PostgreSQL both track length of "characters" and not "bytes"
MAXIMUM_NAME_LENGTH = 255
Function TaskTimer
has 107 lines of code (exceeds 25 allowed). Consider refactoring. Open
jobsworth.tasks.TaskTimer = (function () {
function bind() {
var $ = jQuery;
var self = this;
Method get_action
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def get_action(log)
if log.task && log.task_id > 0
action = 'Completed' if log.event_log.event_type == EventLog::TASK_COMPLETED
action = 'Reverted' if log.event_log.event_type == EventLog::TASK_REVERTED
action = 'Created' if log.event_log.event_type == EventLog::TASK_CREATED
- 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 bindEvents
has 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
TaskTodosEditor.prototype.bindEvents = function () {
var self = this;
$(this.el).on('click', ".toggle-todo-edit", function () {
self.toggleTodoEdit(this);
Function ColumnPicker
has 97 lines of code (exceeds 25 allowed). Consider refactoring. Open
jobsworth.grids.ColumnPicker = (function ($) {
function ColumnPicker(columns, grid, options) {
var $menu;
var columnCheckboxes;
var columnList;
Function ServiceEditor
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
jobsworth.services.ServiceEditor = (function ($) {
function ServiceEditor(options) {
this.options = options;
this.bindEvents();
}
Function ColumnPicker
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
function ColumnPicker(columns, grid, options) {
var $menu;
var columnCheckboxes;
var columnList;
var gear_icon = '<i title="Select Columns" class="icon-cog pull-right"></i>';