ari/jobsworth

View on GitHub

Showing 327 of 327 total issues

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

  function TaskNotificationEditor(options) {
    this.options = options;
    this.el = this.options.el;
    this.initialize();
    this.bindEvents();
Severity: Major
Found in app/assets/javascripts/tasks/task_notification_editor.js and 1 other location - About 1 hr to fix
app/assets/javascripts/tasks/task_todos_editor.js on lines 8..13

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

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 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
Severity: Minor
Found in app/models/notifications.rb - About 1 hr to fix

    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)
    Severity: Minor
    Found in app/helpers/tasks_helper.rb - About 1 hr to fix

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

          respond_to do |format|
            if @resource_type.save
              flash[:success] = t('flash.notice.model_created', model: ResourceType.model_name.human)
              format.html { redirect_to(edit_resource_type_path(@resource_type)) }
              format.xml { render :xml => @resource_type, :status => :created, :location => @resource_type }
      Severity: Major
      Found in app/controllers/resource_types_controller.rb and 1 other location - About 1 hr to fix
      app/controllers/properties_controller.rb on lines 40..47

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

      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

          respond_to do |format|
            if @property.save
              flash[:success] = t('flash.notice.model_created', model: Property.model_name.human)
              format.html { redirect_to(edit_property_path(@property)) }
              format.xml { render :xml => @property, :status => :created, :location => @property }
      Severity: Major
      Found in app/controllers/properties_controller.rb and 1 other location - About 1 hr to fix
      app/controllers/resource_types_controller.rb on lines 32..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 52.

      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

              success: function (response) {
                $('.todo-container').html(response.todos_html);
                $('#todo-status-' + response.task_dom_id).html(response.todos_status);
              }
      Severity: Major
      Found in app/assets/javascripts/tasks/task_todos_editor.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/tasks/task_todos_editor.js on lines 79..82

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

      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

              success: function (response) {
                $('.todo-container').html(response.todos_html);
                $('#todo-status-' + response.task_dom_id).html(response.todos_status);
              }
      Severity: Major
      Found in app/assets/javascripts/tasks/task_todos_editor.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/tasks/task_todos_editor.js on lines 135..138

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

      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 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?
      Severity: Minor
      Found in app/helpers/tasks_helper.rb - About 1 hr 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 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
      Severity: Minor
      Found in app/models/abstract_task.rb - About 1 hr 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 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?
      Severity: Minor
      Found in app/helpers/work_logs_helper.rb - About 1 hr 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 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
      Severity: Minor
      Found in app/helpers/resources_helper.rb - About 1 hr 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 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'
      Severity: Minor
      Found in app/controllers/milestones_controller.rb - About 1 hr 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 UserPermissions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      jobsworth.UserPermissions = (function ($) {
        function UserPermissions(userId) {
          this.userId = userId;
      
          var self = this;
      Severity: Minor
      Found in app/assets/javascripts/user_permissions.js - About 1 hr to fix

        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 = []
        Severity: Minor
        Found in app/models/search.rb - About 1 hr to fix

          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();
          Severity: Minor
          Found in app/assets/javascripts/ajax_spinner.js - About 1 hr to fix

            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])
            Severity: Minor
            Found in app/controllers/projects_controller.rb - About 1 hr to fix

              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();
              Severity: Minor
              Found in app/assets/javascripts/task.js - About 1 hr to fix

                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,
                Severity: Minor
                Found in app/models/mailman.rb - About 1 hr to fix

                  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?
                  Severity: Minor
                  Found in app/helpers/tasks_helper.rb - About 1 hr to fix

                    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
                    Severity: Minor
                    Found in app/models/user.rb - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language