ari/jobsworth

View on GitHub

Showing 327 of 327 total issues

Method remove has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def remove(perm)
    case perm
      when 'comment' then
        self.can_comment = false
      when 'work' then
Severity: Minor
Found in app/models/project_permission.rb - About 1 hr to fix

    Method add_email_to_task has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def add_email_to_task(wrapper, task)
        files = save_attachments(wrapper, task)
    
        # if it's from unknown, add email to task email_addresses
        unless wrapper.user or task.email_addresses.include? wrapper.email_address
    Severity: Minor
    Found in app/models/mailman.rb - About 1 hr to fix

      Method update_group has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def update_group(user, group, value, icon = nil)
          if group == 'milestone'
            val_arr = value.split('/')
            task_project = user.projects.find_by(:name => val_arr[0])
            if user.can?(task_project, 'milestone')
      Severity: Minor
      Found in app/models/task_record.rb - About 1 hr to fix

        Method initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(email)
              @from = email.from.first
              @body = Email.get_body(email)
              @subject = email.subject
              @email = email
        Severity: Minor
        Found in app/models/mailman.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 parse_time has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.parse_time(input)
            return 0 unless input.present?
            total = 0
            input = input.split('h')
            if input.size > 1
        Severity: Minor
        Found in app/models/time_parser.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 generate_name has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def generate_name
            counter = 0
            arr=[]
            types=['Project', 'Milestone', 'Status', 'Client', 'User']
            types.each do |type|
        Severity: Minor
        Found in app/models/task_filter.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 task_graph_extracted_from_show has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def task_graph_extracted_from_show
            start, step, interval, range, tick = @widget.calculate_start_step_interval_range_tick(tz)
        
            filter = filter_from_filter_by
        
        
        Severity: Minor
        Found in app/controllers/widgets_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

        Method schedule_tasks has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def schedule_tasks(options={})
            options[:limit] ||= 1000000
            options[:save] = true unless options.key?(:save)
        
            if options[:save]
        Severity: Minor
        Found in app/models/user.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 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            @user = User.new(user_create_params)
            @user.company_id = current_user.company_id
            @user.email = params[:email]
        
        
        Severity: Minor
        Found in app/controllers/users_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

        Method due_in_css has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def due_in_css(task)
            css = ''
            return css if task.resolved?
            due_date= task.due_date
            if due_date
        Severity: Minor
        Found in app/helpers/application_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 get_days_of_week_header has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def get_days_of_week_header(w)
            if [0, 1, 2].include? @range.to_i
              I18n.l(tz.utc_to_local(w.started_at), format: '%a <br/>%d/%m').html_safe
            elsif [3, 4].include? @range.to_i
              if tz.utc_to_local(w.started_at).beginning_of_week.month != tz.utc_to_local(w.started_at).beginning_of_week.since(6.days).month
        Severity: Minor
        Found in app/models/worklog_report.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_dependency_attributes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def set_dependency_attributes(dependency_params, user)
            return if dependency_params.nil?
        
            new_dependencies = []
            dependency_params.each do |d|
        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

        Function actionFilterClick has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          Filter.prototype.actionFilterClick = function (link) {
            var sender = $(link);
            var tf_id = sender.parent().parent().attr("id").split("_")[1];
            
            if (sender.hasClass('do_hide') || sender.hasClass('do_show')) {
        Severity: Minor
        Found in app/assets/javascripts/filter.js - About 1 hr to fix

          Method build_work_added_or_comment has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.build_work_added_or_comment(task, user, params=nil)
              work_log_params=params[:work_log].nil? ? {} : params[:work_log].clone
              if (work_log_params and !work_log_params[:duration].blank?) or (params and !params[:comment].blank?)
                unless params[:comment].blank?
                  work_log_params[:body] = params[:comment]
          Severity: Minor
          Found in app/models/work_log.rb - About 1 hr to fix

            Method create has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def create
                @user = User.new(user_create_params)
                @user.company_id = current_user.company_id
                @user.email = params[:email]
            
            
            Severity: Minor
            Found in app/controllers/users_controller.rb - About 1 hr to fix

              Method create has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def create
                  @task.task_due_calculation(params[:task][:due_at], current_user)
                  @task.duration = TimeParser.parse_time(params[:task][:duration])
                  @task.duration = 0 if @task.duration.nil?
                  if @task.service_id == -1
              Severity: Minor
              Found in app/controllers/tasks_controller.rb - About 1 hr to fix

                Function bind has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  Planning.prototype.bind = function () {
                    var self = this;
                
                    $(".next_tasks_panel a.more_tasks").live("click", function () {
                      var parent = $(this).parents(".next_tasks_panel");
                Severity: Minor
                Found in app/assets/javascripts/tasks/planning.js - About 1 hr to fix

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

                    function TaskTodosEditor(options) {
                      this.options = options;
                      this.el = this.options.el;
                      this.initialize();
                      this.bindEvents();
                  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_notification_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

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

                      $("#service-edit-autocomplete-for-service").autocomplete({
                        source: "/services/auto_complete_for_service_name",
                        delay: 800,
                        minlength: 3,
                        select: function (e, ui) {
                  Severity: Major
                  Found in app/assets/javascripts/services.js and 1 other location - About 1 hr to fix
                  app/assets/javascripts/services.js on lines 67..74

                  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

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

                      $("#service-edit-autocomplete-for-customer").autocomplete({
                        source: "/customers/auto_complete_for_customer_name",
                        delay: 800,
                        minlength: 3,
                        select: function (e, ui) {
                  Severity: Major
                  Found in app/assets/javascripts/services.js and 1 other location - About 1 hr to fix
                  app/assets/javascripts/services.js on lines 77..84

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language