Showing 358 of 358 total issues
Method index
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
@go_to_default_path = !(params.has_key?(:year) && params.has_key?(:month))
@current_date = Time.current
date_set = if @go_to_default_path
Function webforms
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function webforms(){
// Run through HTML5's new input attributes to see if the UA understands any.
// We're using f which is the <input> element created early on
// Mike Taylr has created a comprehensive resource for testing these attributes
Function initialize
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
initialize: function(target_element, options) {
this.target_element = $(target_element); // make sure it's an element, not a string
if (!this.target_element) { alert("Target element " + target_element + " not found!"); return false;}
if (this.target_element.tagName != "INPUT") this.target_element = this.target_element.down("INPUT")
Method archive
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def archive
authorize! :update, @task_list
calc_onindex
if !@task_list.archived
Method hours_js
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def hours_js(year, month, comments)
taskmap = {}
projectmap = {}
organizationmap = {}
Method loading_divider_form
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def loading_divider_form(toggle,id=nil)
if toggle
page["divider_form_loading#{"_#{id}" if id}"].show
page["divider_submit#{"_#{id}" if id}"].hide
else
- 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 to_api_hash
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def to_api_hash(options = {})
base = {
:id => id,
:project_id => project_id,
:user_id => user_id,
- 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 loading_note_form
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def loading_note_form(toggle,id=nil)
if toggle
page["note_form_loading#{"_#{id}" if id}"].show
page["note_submit#{"_#{id}" if id}"].hide
else
- 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 index
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def index
@go_to_default_path = !(params.has_key?(:year) && params.has_key?(:month))
@current_date = Time.current
date_set = if @go_to_default_path
- 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 parseFormattedString
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Date.parseFormattedString = function (string) {
var regexp = '([0-9]{1,2})\.(([0-9]{1,2})\.(([0-9]{2,4})( ([0-9]{1,2}):([0-9]{2})? *)?)?)?';
var d = string.match(new RegExp(regexp, "i"));
if (d==null) return Date.parse(string); // at least give javascript a crack at it.
var offset = 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 post_check_state
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def post_check_state
if type_name == :export
Emailer.send_with_language(:notify_export, user.locale, self.id) if @dispatch_notification
TeamboxData.send_later(:delayed_export, self.id) if @dispatch_export
elsif type_name == :import
- 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 js_id
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def js_id(*args)
if args.is_a?(Array)
element = args[0].is_a?(String) || args[0].is_a?(Symbol) ? args[0] : nil
models = args.slice(1,args.size-1)
raise ArgumentError unless models.all?{|a|a.is_a?(ActiveRecord::Base)}
- 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 parseFormattedString
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Date.parseFormattedString = function (string) {
var regexp = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})" +
"( ([0-9]{1,2}):([0-9]{2})?" +
"?)?)?)?";
- 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 activity_title
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def activity_title(activity, plain = false, mobile = false)
values = mobile ? { :user => (plain ? h(activity.user.short_name) : "<span class='user'>#{h activity.user.short_name}</span>") } :
{ :user => link_to_unless(plain, h(activity.user.name), activity.user) }
case activity
- 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 InsertHereFunc
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
var InsertHereFunc = function(evt){
if (!InsertHere.enabled)
return;
var el = $(evt.target);
- 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
authorize! :admin, @target
if @target != current_user
user_or_email = params[:user_or_email]
role = params || Person::ROLES[:participant]
- 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 download
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def download
head(:forbidden) and return unless @data.downloadable?(current_user)
if Teambox.config.amazon_s3
redirect_to @data.processed_data.url
- 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
# pass the project so target.project lookup can be skipped
authorize! :comment, target, @current_project
comment = target.comments.create_by_user current_user, params[:comment]
- 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
Identical blocks of code found in 3 locations. Consider refactoring. Open
if Array(options[:include]).include? :thread_comments
base[:first_comment] = first_comment.to_api_hash(options) if first_comment
base[:recent_comments] = recent_comments.map{|c|c.to_api_hash(options)}
elsif !Array(options[:include]).include?(:comments)
base[:first_comment_id] = first_comment.try(: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 50.
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
Identical blocks of code found in 3 locations. Consider refactoring. Open
if Array(options[:include]).include? :thread_comments
base[:first_comment] = first_comment.to_api_hash(options) if first_comment
base[:recent_comments] = recent_comments.map{|c|c.to_api_hash(options)}
elsif !Array(options[:include]).include?(:comments)
base[:first_comment_id] = first_comment.try(: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 50.
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