ari/jobsworth

View on GitHub

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 = {}
Severity: Minor
Found in app/models/worklog_report.rb - About 5 hrs 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

Class User has 43 methods (exceeds 20 allowed). Consider refactoring.
Open

class User < ActiveRecord::Base

  devise :database_authenticatable, :registerable, :encryptable,
         :recoverable, :rememberable, :trackable

Severity: Minor
Found in app/models/user.rb - About 5 hrs to fix

    Function Filter has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

    jobsworth.Filter = (function ($) {
      function Filter() {
        this.init();
        this.bind();
      }
    Severity: Minor
    Found in app/assets/javascripts/filter.js - About 5 hrs 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 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
    Severity: Major
    Found in app/controllers/feeds_controller.rb - About 5 hrs to fix

      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();
      Severity: Major
      Found in app/assets/javascripts/tasks/task_todos_editor.js - About 5 hrs to fix

        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;
        Severity: Major
        Found in app/assets/javascripts/tasks/task_details_editor.js - About 5 hrs to fix

          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
          Severity: Major
          Found in app/assets/javascripts/services.js and 1 other location - About 4 hrs to fix
          app/assets/javascripts/services.js on lines 13..27

          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

          Further Reading

          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
          Severity: Major
          Found in app/assets/javascripts/services.js and 1 other location - About 4 hrs to fix
          app/assets/javascripts/services.js on lines 29..43

          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

          Further Reading

          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;
          Severity: Minor
          Found in app/assets/javascripts/tasks/task_editor.js - About 4 hrs 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

          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]
          Severity: Minor
          Found in app/controllers/tasks_controller.rb - About 4 hrs to fix

            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)
            Severity: Minor
            Found in app/models/worklog_report.rb - About 4 hrs 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 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
            Severity: Minor
            Found in app/models/worklog_report.rb - About 4 hrs 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 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')
            Severity: Minor
            Found in app/models/worklog_report.rb - About 4 hrs 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

            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
            
            
            Severity: Minor
            Found in app/models/task_filter.rb - About 4 hrs to fix

              Function TaskTimer has 107 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              jobsworth.tasks.TaskTimer = (function () {
              
                function bind() {
                  var $ = jQuery;
                  var self = this;
              Severity: Major
              Found in app/assets/javascripts/tasks/timer.js - About 4 hrs to fix

                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
                Severity: Minor
                Found in app/controllers/feeds_controller.rb - About 4 hrs 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 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);
                Severity: Major
                Found in app/assets/javascripts/tasks/task_todos_editor.js - About 4 hrs to fix

                  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;
                  Severity: Major
                  Found in app/assets/javascripts/grids/columnpicker.js - About 3 hrs to fix

                    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();
                      }
                    Severity: Major
                    Found in app/assets/javascripts/services.js - About 3 hrs to fix

                      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>';
                      Severity: Major
                      Found in app/assets/javascripts/grids/columnpicker.js - About 3 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language