ari/jobsworth

View on GitHub

Showing 327 of 327 total issues

Method users_to_notify has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def users_to_notify(user_who_made_change=nil)
    if user_who_made_change and !user_who_made_change.receive_own_notifications?
      recipients= self.users.active.where('users.id != ? and users.receive_notifications = ?', user_who_made_change.id || 0, true)
    else
      recipients= self.users.active.where(:receive_notifications => true)
Severity: Minor
Found in app/models/task_record.rb - About 45 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 fire has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def self.fire(task, fire_on)
    triggers = task.company.triggers.where(:event_id => fire_on)
    match = "tasks.id = #{ task.id }"

    triggers.each do |trigger|
Severity: Minor
Found in app/models/trigger.rb - About 45 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 select has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        select: function (start, end, allDay, jsEvent, view, resource) {
Severity: Minor
Found in app/assets/javascripts/calendar.js - About 45 mins to fix

    Method task_detail has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def task_detail(task, user = current_user)
        task.due_at ||= task.milestone.due_at if task.milestone
        options = {
            task.human_name(:status) => task.human_value(:open_or_closed),
            task.human_name(:project) => task.project.name,
    Severity: Minor
    Found in app/helpers/tasks_helper.rb - About 45 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 protected_area has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def protected_area
        @user = User.where('company_id = ?', current_user.company_id).find_by(:id => params[:id]) if params[:id]
    
        if Setting.contact_creation_allowed
          unless current_user.admin? or current_user.edit_clients? or current_user == @user
    Severity: Minor
    Found in app/controllers/users_controller.rb - About 45 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_resource_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def auto_complete_for_resource_name
        return unless current_user.use_resources?
    
        search = params[:term]
        search = search.split(',').last if search
    Severity: Minor
    Found in app/controllers/tasks_controller.rb - About 45 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 due_date has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def due_date
        unless @due_date
          if due_at.nil?
            last = self.tasks.collect { |t| t.due_at.to_time.to_f if t.due_at }.compact.sort.last
            @due_date = Time.at(last).to_datetime if last
    Severity: Minor
    Found in app/models/milestone.rb - About 45 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

    Avoid deeply nested control flow statements.
    Open

            body += "<option value='2' #{selected='selected' if w.rejected? } >#{I18n.t('work_logs.status.rejected')}</option>"
    Severity: Major
    Found in app/models/worklog_report.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

              body += "<option value='0' #{selected='selected' if w.status.to_i.zero? } >--</option>"
      Severity: Major
      Found in app/models/worklog_report.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                body += "<option value='1' #{selected='selected' if w.approved? } >#{I18n.t('work_logs.status.approved')}</option>"
        Severity: Major
        Found in app/models/worklog_report.rb - About 45 mins to fix

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

              this.grid.onColumnsReordered.subscribe(function (e) {
                store.set('grid.Columns', self.grid.getColumns());
              });
          Severity: Minor
          Found in app/assets/javascripts/grid.js and 1 other location - About 40 mins to fix
          app/assets/javascripts/grid.js on lines 160..162

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

          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

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

                for (var index in columns) {
                  if (columns[index].id == value) {
                    self.groupBy(columns[index]);
                    return;
                  }
          Severity: Minor
          Found in app/assets/javascripts/grid.js and 1 other location - About 40 mins to fix
          app/assets/javascripts/grid.js on lines 120..125

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

          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

              this.grid.onColumnsResized.subscribe(function (e) {
                store.set('grid.Columns', self.grid.getColumns());
              });
          Severity: Minor
          Found in app/assets/javascripts/grid.js and 1 other location - About 40 mins to fix
          app/assets/javascripts/grid.js on lines 156..158

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

          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

                $(".groupByOptions").hover(function () {
                  $(".groupByOptions >ul").show();
                  $(".columnList >ul").hide();
                });
          Severity: Minor
          Found in app/assets/javascripts/grids/columnpicker.js and 1 other location - About 40 mins to fix
          app/assets/javascripts/grids/columnpicker.js on lines 99..102

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

          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

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

                for (var index in columns) {
                  if (columns[index].id == value) {
                    self.groupBy(columns[index]);
                    return;
                  }
          Severity: Minor
          Found in app/assets/javascripts/grid.js and 1 other location - About 40 mins to fix
          app/assets/javascripts/grid.js on lines 98..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 48.

          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

                $(".columnList").hover(function () {
                  $(".columnList >ul").show();
                  $(".groupByOptions >ul").hide();
                });
          Severity: Minor
          Found in app/assets/javascripts/grids/columnpicker.js and 1 other location - About 40 mins to fix
          app/assets/javascripts/grids/columnpicker.js on lines 104..107

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

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

            function DurationFormatter(row, cell, value, _columnDef, dataContext) {
          Severity: Minor
          Found in app/assets/javascripts/grid.js - About 35 mins to fix

            Function show_widget has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              Portal.prototype.show_widget = function (id, dom_id, type, configured, gadget_url) {
            Severity: Minor
            Found in app/assets/javascripts/widget.js - About 35 mins to fix

              Method selected_filter_values has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def selected_filter_values(name, selected_names_and_ids, label = nil, default_label_text = 'Any', &block)
              Severity: Minor
              Found in app/helpers/resources_helper.rb - About 35 mins to fix

                Method reminder has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def reminder(tasks, tasks_tomorrow, tasks_overdue, user, sent_at = Time.now)
                Severity: Minor
                Found in app/models/notifications.rb - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language