ari/jobsworth

View on GitHub

Showing 267 of 327 total issues

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

        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

            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

                            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
                                Severity
                                Category
                                Status
                                Source
                                Language