Showing 267 of 327 total issues
Method create
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@user = User.new(user_create_params)
@user.company_id = current_user.company_id
@user.email = params[:email]
Method create
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@task.task_due_calculation(params[:task][:due_at], current_user)
@task.duration = TimeParser.parse_time(params[:task][:duration])
@task.duration = 0 if @task.duration.nil?
if @task.service_id == -1
Function bind
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Planning.prototype.bind = function () {
var self = this;
$(".next_tasks_panel a.more_tasks").live("click", function () {
var parent = $(this).parents(".next_tasks_panel");
Method changed
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def changed(delivery)
@user = delivery.work_log.user
@task = delivery.work_log.task
@recipient = delivery.email
@comment = delivery.work_log.body
Method human_future_date
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def human_future_date(date, tz)
return t('shared.unknown') unless date
tz_day_end = tz.now.end_of_day
local_date = tz.utc_to_local(date.utc)
Method due_date_field
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def due_date_field(task, permissions)
task_due_at = task.due_at.nil? ? '' : task.due_at.utc.strftime(current_user.date_format)
milestone_due_at = task.milestone.try(:due_at)
placeholder = milestone_due_at.nil? ? '' : milestone_due_at.strftime(current_user.date_format)
date_tooltip = if task.due_at.nil? && !milestone_due_at.nil?
- 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 set_tags=
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def set_tags=(tagstring)
return false if (tagstring.nil? or tagstring.gsub(' ', '') == self.tagstring.gsub(' ', ''))
self.tags.clear
tagstring.split(',').each do |t|
tag_name = t.downcase.strip
- 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 work_log_status_options
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def work_log_status_options
options = []
options << [t('work_logs.status_options.leave_open'), 0] if @task.open?
options << [t('work_logs.status_options.reopen'), 0] if @task.resolved?
options << [t('work_logs.status_options.close'), 1] if @task.open?
- 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 value_field
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def value_field(attribute, name_prefix, field_id, show_remove_link = false)
type = attribute.resource_type_attribute
value = attribute.value
if attribute.new_record? and type.is_password?
value = User.model_name.human
- 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
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def create
@milestone = Milestone.new(milestone_attributes)
unless current_user.can?(@milestone.project, 'milestone')
flash[:error] = t('flash.alert.access_denied_to_model', model: Project.human_attribute_name(:milestones))
redirect_to '/activities'
- 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 UserPermissions
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
jobsworth.UserPermissions = (function ($) {
function UserPermissions(userId) {
this.userId = userId;
var self = this;
Method search_conditions_for
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.search_conditions_for(strings, fields = [:name], options = {})
search_by_id = options.has_key?(:search_by_id) ? options[:search_by_id] : true
id_field= options.has_key?(:table) ? "#{options[:table]}.id" : 'id'
conds = []
Function AjaxSpinner
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
jobsworth.AjaxSpinner = (function ($) {
function AjaxSpinner(element) {
this.element = element;
this.count = 0;
this.bind();
Method ajax_add_permission
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ajax_add_permission
user = User.active.where('company_id = ?', current_user.company_id).find(params[:user_id])
if current_user.admin?
@project = current_user.company.projects.find(params[:id])
Function init
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Task.prototype.init = function () {
$('#taskform').bind("ajax:success", function (event, json, xhr) {
authorize_ajax_form_callback(json);
var task = json;
$('#errorExplanation').remove();
Method create_task_from_email
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_task_from_email(wrapper, project)
task = TaskRecord.new(
:name => wrapper.subject,
:project => project,
:company => project.company,
Method due_date_field
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def due_date_field(task, permissions)
task_due_at = task.due_at.nil? ? '' : task.due_at.utc.strftime(current_user.date_format)
milestone_due_at = task.milestone.try(:due_at)
placeholder = milestone_due_at.nil? ? '' : milestone_due_at.strftime(current_user.date_format)
date_tooltip = if task.due_at.nil? && !milestone_due_at.nil?
Method generate_widgets
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_widgets
w = new_widget
w.name = I18n.t('widgets.top_tasks')
w.widget_type = 0
w.number = 5
Method to_tip
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_tip(options = {})
user = options[:user]
utz = user.tz
unless @tip
Method milestones_to_select_tag
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def milestones_to_select_tag(milestones)
options = [%Q[<option value="0" title="#{t('forms.select.please_select')}">#{t('forms.select.none')}</option>]] + milestones.collect do |milestone|
date = milestone.due_at.nil? ? t('shared.not_set') : l(milestone.due_at, format: current_user.date_format)
selected = if (@task.milestone_id == milestone.id) || (@task.milestone_id.nil? && milestone.id == '0')