ari/jobsworth

View on GitHub

Showing 327 of 327 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def update
    @log.attributes = work_log_params
    @log.project = @task.project

    if @log.save
Severity: Minor
Found in app/controllers/work_logs_controller.rb and 1 other location - About 35 mins to fix
app/controllers/work_logs_controller.rb on lines 13..23

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 36.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def create
    @log.user = current_user
    @log.project = @task.project

    if @log.save
Severity: Minor
Found in app/controllers/work_logs_controller.rb and 1 other location - About 35 mins to fix
app/controllers/work_logs_controller.rb on lines 29..39

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 36.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    $(document).on("click", ".widget a.toggle-display", function () {
      var widget_id = $(this).parents(".widget").data("widget-id");
      self.widget_toggle_display(widget_id);
      return false;
    });
Severity: Minor
Found in app/assets/javascripts/widget.js and 1 other location - About 35 mins to fix
app/assets/javascripts/email_addresses.js on lines 26..30

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 47.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    $('.email_address .set-default').live('click', function () {
      var id = $(this).parents('.email_address').data('id');
      self.setDefault(id);
      return false;
    });
Severity: Minor
Found in app/assets/javascripts/email_addresses.js and 1 other location - About 35 mins to fix
app/assets/javascripts/widget.js on lines 64..68

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 47.

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

Further Reading

Method target_for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def target_for(email, company)
    logger.tagged('EMAIL TRACKING') { logger.info 'target_for email' }
    logger.tagged('EMAIL TRACKING') { logger.info email }

    logger.tagged('EMAIL TRACKING') { logger.info 'target_for company' }
Severity: Minor
Found in app/models/mailman.rb - About 35 mins to fix

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 TaskTimer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

jobsworth.tasks.TaskTimer = (function () {

  function bind() {
    var $ = jQuery;
    var self = this;
Severity: Minor
Found in app/assets/javascripts/tasks/timer.js - About 35 mins to fix

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 properties= has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def properties=(params)
    ids=[]
    attributes= params.collect { |prop_id, val_id|
      # task_property_values may be changed elsewhere
      # discards the cached copy of task_property_values
Severity: Minor
Found in app/models/abstract_task.rb - About 35 mins to fix

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 do_update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def do_update(params, user)
    if self.wait_for_customer and !params[:comment].blank?
      self.wait_for_customer = false
      params[:task].delete(:wait_for_customer)
    end
Severity: Minor
Found in app/models/abstract_task.rb - About 35 mins to fix

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 multi_links has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def multi_links(custom_attribute_value)
    res = ''
    value = custom_attribute_value
    attr = value.custom_attribute

Severity: Minor
Found in app/helpers/application_helper.rb - About 35 mins to fix

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 7 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    @tags = Tag.top_counts(current_user.company)
    @users = User.order('name').where('users.company_id = ?', current_user.company_id).joins('INNER JOIN project_permissions ON project_permissions.user_id = users.id')
    @custom_attributes = current_user.company.custom_attributes.by_type('WorkLog')
    options = params[:report]
Severity: Minor
Found in app/controllers/billing_controller.rb - About 35 mins to fix

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 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    # try link orphaned email address first
    @email_address = current_user.company.email_addresses.where(:email => params[:email_address][:email]).where('user_id IS NULL').first
    @email_address ||= EmailAddress.new(email_address_params)

Severity: Minor
Found in app/controllers/email_addresses_controller.rb - About 35 mins to fix

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 ajax_add_permission has a Cognitive Complexity of 7 (exceeds 5 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])
Severity: Minor
Found in app/controllers/projects_controller.rb - About 35 mins to fix

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 auto_complete_for_user_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def auto_complete_for_user_name
    if (term = params[:term]).present?
      # the next line searches for names starting with given text OR surname (space started) starting with text of the active users
      @users = current_user.company.users.active.search_by_name(term).limit(50)

Severity: Minor
Found in app/controllers/users_controller.rb - About 35 mins to fix

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 can? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def can?(project, perm)
    return true if project.nil? or admin?

    @perm_cache ||= {}
    unless @perm_cache[project.id]
Severity: Minor
Found in app/models/user.rb - About 35 mins to fix

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 score_rules has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def score_rules
    score_rules = []

    # Query scores only if company is using score rules
    if company.use_score_rules?
Severity: Minor
Found in app/models/task_record.rb - About 35 mins to fix

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 load_customer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def load_customer
    id = params[:customer_id]
    id ||= params[:organizational_unit][:customer_id] if params[:organizational_unit]

    if id
Severity: Minor
Found in app/controllers/organizational_units_controller.rb - About 35 mins to fix

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_logs_for_timeline has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.event_logs_for_timeline(current_user, params)
    tz = TZInfo::Timezone.new(current_user.time_zone)
    now = tz.now

    filter_project = params[:filter_project].to_i
Severity: Minor
Found in app/models/event_log.rb - About 35 mins to fix

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_attachments has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create_attachments(files_array, current_user)
    attachments =
        if files_array.blank? || files_array.reject(&:blank?).empty?
          []
        else
Severity: Minor
Found in app/models/abstract_task.rb - About 35 mins to fix

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

      intervals.each_with_index do |interval, index|
        counts[:work][index] = mine_work_logs_sum(interval.first, interval.second)
        counts[:completed][index] = mine_tasks_count_completed(interval.first, interval.second)
        counts[:created][index] = mine_tasks_count_created(interval.first, interval.second)
Severity: Minor
Found in app/models/widget.rb and 1 other location - About 35 mins to fix
app/models/widget.rb on lines 100..103

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 35.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      intervals.each_with_index do |interval, index|
        counts[:work][index] = work_logs_sum(interval.first, interval.second)
        counts[:completed][index] = tasks_count_completed(interval.first, interval.second)
        counts[:created][index] = tasks_count_created(interval.first, interval.second)
Severity: Minor
Found in app/models/widget.rb and 1 other location - About 35 mins to fix
app/models/widget.rb on lines 94..97

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 35.

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

Further Reading

Severity
Category
Status
Source
Language