ari/jobsworth

View on GitHub

Showing 327 of 327 total issues

Method to_tip has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def to_tip(options = {})
    user = options[:user]
    utz = user.tz

    unless @tip
Severity: Minor
Found in app/models/abstract_task.rb - About 1 hr to fix

    Method milestones_to_select_tag has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def milestones_to_select_tag(milestones)
        options = [%Q[<option value="0" title="#{t('forms.select.please_select')}">#{t('forms.select.none')}</option>]] + milestones.collect do |milestone|
          date = milestone.due_at.nil? ? t('shared.not_set') : l(milestone.due_at, format: current_user.date_format)
    
          selected = if (@task.milestone_id == milestone.id) || (@task.milestone_id.nil? && milestone.id == '0')
    Severity: Minor
    Found in app/helpers/tasks_helper.rb - About 1 hr to fix

      Function eventDrop has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              eventDrop: function (event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) {
      Severity: Major
      Found in app/assets/javascripts/calendar.js - About 1 hr to fix

        Method attach_customers_to_task has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def attach_customers_to_task(task)
            task.users.each do |user|
              if user.customer and !task.customers.include?(user.customer)
                task.customers << user.customer
                user.customer.users.auto_add.each do |u|
        Severity: Minor
        Found in app/models/mailman.rb - About 55 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 name has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def name
            res = ''
            if self.filter_by && self.filter_by.length > 0
              begin
                res << case self.filter_by[0..0]
        Severity: Minor
        Found in app/models/widget.rb - About 55 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 format_duration has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.format_duration(minutes, spent = false)
            if minutes.present?
              hours, minutes = (minutes / 60), minutes % 60
              if hours == 0 && minutes != 0
                "#{minutes}m"
        Severity: Minor
        Found in app/models/time_parser.rb - About 55 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 update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def update
            @task = AbstractTask.accessed_by(current_user).find_by(:id => params[:id])
            if @task.nil?
              flash[:error] = t('flash.error.not_exists_or_no_permission', model: TaskRecord.model_name.human)
              redirect_from_last and return
        Severity: Minor
        Found in app/controllers/tasks_controller.rb - About 55 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 options_for_task_services has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def options_for_task_services(customers, task)
            services = []
            customers.each { |c| services.concat(c.services.all) }
            services = services.uniq
        
        
        Severity: Minor
        Found in app/helpers/tasks_helper.rb - About 55 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 github_parser has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def ScmChangeset.github_parser(payload)
            payload = JSON.parse(payload)
            payload['commits'].collect do |commit|
              changeset= {}
              changeset[:changeset_rev]= commit['id']
        Severity: Minor
        Found in app/models/scm_changeset.rb - About 55 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 init_work_logs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def init_work_logs(tasks, params)
            logs = []
        
            ids = tasks.collect { |t| t.id }
            logs = WorkLog.level_accessed_by(current_user).where('task_id in (?)', ids).includes(:project, :_user_, :customer, :company => [:custom_attributes], :task => [:tags, :milestone])
        Severity: Minor
        Found in app/models/worklog_report.rb - About 55 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 google_parser has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def ScmChangeset.google_parser(payload)
            payload = JSON.parse(payload)
            payload['revisions'].collect do |commit|
              changeset= {}
              changeset[:changeset_rev]= commit['revision']
        Severity: Minor
        Found in app/models/scm_changeset.rb - About 55 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_from_web_hook has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def ScmChangeset.create_from_web_hook(params)
            scm_project = ScmProject.find_by(:secret_key => params[:secret_key])
            if scm_project.nil?
              return false
            end
        Severity: Minor
        Found in app/models/scm_changeset.rb - About 55 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 avatar_url has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def avatar_url(size=32, secure = false)
            if avatar?
              if size > 25 && File.exist?(avatar_large_path)
                '/users/avatar/'+id.to_s+'?large=1'
              else
        Severity: Minor
        Found in app/models/user.rb - About 55 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

            respond_to do |format|
              if saved
                flash[:success] = t('flash.notice.model_updated', model: Property.model_name.human)
                format.html { redirect_to(edit_property_path(@property)) }
                format.xml { head :ok }
        Severity: Minor
        Found in app/controllers/properties_controller.rb and 1 other location - About 55 mins to fix
        app/controllers/resource_types_controller.rb on lines 54..61

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

        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 saved
                flash[:success] = t('flash.notice.model_updated', model: ResourceType.model_name.human)
                format.html { redirect_to(edit_resource_type_path(@resource_type)) }
                format.xml { head :ok }
        Severity: Minor
        Found in app/controllers/resource_types_controller.rb and 1 other location - About 55 mins to fix
        app/controllers/properties_controller.rb on lines 64..71

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

        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

                (I18n.t('shared.week') + "#{tz.utc_to_local(w.started_at).strftime('%W').to_i + 1} <br/>" +
                    I18n.l(tz.utc_to_local(w.started_at).beginning_of_week, format: '%d/%m') + ' - ' +
                    I18n.l(tz.utc_to_local(w.started_at).beginning_of_week.since(6.days), format: '%d/%m')
        Severity: Minor
        Found in app/models/worklog_report.rb and 1 other location - About 55 mins to fix
        app/models/worklog_report.rb on lines 474..476

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

        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

                  (I18n.t('shared.week') + "#{tz.utc_to_local(w.started_at).strftime('%W').to_i + 1} <br/>" +
                      I18n.l(tz.utc_to_local(w.started_at).beginning_of_month, format: '%d/%m') + ' - ' +
                      I18n.l(tz.utc_to_local(w.started_at).beginning_of_week.since(6.days), format: '%d/%m')
        Severity: Minor
        Found in app/models/worklog_report.rb and 1 other location - About 55 mins to fix
        app/models/worklog_report.rb on lines 480..482

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

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

                eventResize: function (event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view) {
        Severity: Major
        Found in app/assets/javascripts/calendar.js - About 50 mins to fix

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

            def attach_user_or_email_address(email, task, users)
              user = task.project.company.users.active.by_email(email.strip).first
              if user
                users << user
              elsif !task.company.suppressed_emails.include?(email.strip)
          Severity: Minor
          Found in app/models/mailman.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 column_name_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def column_name_for(class_type)
              if class_type == 'User'
                return "task_users.type= 'TaskOwner' AND task_users.user_id"
              elsif class_type == 'Project'
                return 'tasks.project_id'
          Severity: Minor
          Found in app/models/task_filter.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

          Severity
          Category
          Status
          Source
          Language