crewmate/crewmate

View on GitHub

Showing 358 of 358 total issues

Method index has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def index
    @go_to_default_path = !(params.has_key?(:year) && params.has_key?(:month))
    @current_date = Time.current

    date_set = if @go_to_default_path
Severity: Minor
Found in app/controllers/hours_controller.rb - About 1 hr to fix

    Function webforms has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function webforms(){
        
            // Run through HTML5's new input attributes to see if the UA understands any.
            // We're using f which is the <input> element created early on
            // Mike Taylr has created a comprehensive resource for testing these attributes
    Severity: Minor
    Found in app/javascripts/modernizr.js - About 1 hr to fix

      Function initialize has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        initialize: function(target_element, options) {
          this.target_element = $(target_element); // make sure it's an element, not a string
          if (!this.target_element) { alert("Target element " + target_element + " not found!"); return false;}
          if (this.target_element.tagName != "INPUT") this.target_element = this.target_element.down("INPUT")
          
      Severity: Minor
      Found in public/javascripts/calendar_date_select/calendar_date_select.js - About 1 hr to fix

        Method archive has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def archive
            authorize! :update, @task_list
            calc_onindex
        
            if !@task_list.archived
        Severity: Minor
        Found in app/controllers/task_lists_controller.rb - About 1 hr to fix

          Method hours_js has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def hours_js(year, month, comments)
              taskmap = {}
              projectmap = {}
              organizationmap = {}
          
          
          Severity: Minor
          Found in app/helpers/calendars_helper.rb - About 1 hr to fix

            Method loading_divider_form has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def loading_divider_form(toggle,id=nil)
                if toggle
                  page["divider_form_loading#{"_#{id}" if id}"].show
                  page["divider_submit#{"_#{id}" if id}"].hide
                else
            Severity: Minor
            Found in app/helpers/page_dividers_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 to_api_hash has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def to_api_hash(options = {})
                base = {
                  :id => id,
                  :project_id => project_id,
                  :user_id => user_id,
            Severity: Minor
            Found in app/models/task_list/conversions.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 loading_note_form has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def loading_note_form(toggle,id=nil)
                if toggle
                  page["note_form_loading#{"_#{id}" if id}"].show
                  page["note_submit#{"_#{id}" if id}"].hide
                else
            Severity: Minor
            Found in app/helpers/page_notes_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 index has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def index
                @go_to_default_path = !(params.has_key?(:year) && params.has_key?(:month))
                @current_date = Time.current
            
                date_set = if @go_to_default_path
            Severity: Minor
            Found in app/controllers/hours_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 parseFormattedString has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            Date.parseFormattedString = function (string) {
              var regexp = '([0-9]{1,2})\.(([0-9]{1,2})\.(([0-9]{2,4})( ([0-9]{1,2}):([0-9]{2})? *)?)?)?';
              var d = string.match(new RegExp(regexp, "i"));
              if (d==null) return Date.parse(string); // at least give javascript a crack at it.
              var offset = 0;
            Severity: Minor
            Found in public/javascripts/calendar_date_select/format_finnish.js - 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 post_check_state has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def post_check_state
                if type_name == :export
                  Emailer.send_with_language(:notify_export, user.locale, self.id) if @dispatch_notification
                  TeamboxData.send_later(:delayed_export, self.id) if @dispatch_export
                elsif type_name == :import
            Severity: Minor
            Found in app/models/teambox_data.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 js_id has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def js_id(*args)
                if args.is_a?(Array)
                  element = args[0].is_a?(String) || args[0].is_a?(Symbol) ? args[0] : nil
                  models = args.slice(1,args.size-1)
                  raise ArgumentError unless models.all?{|a|a.is_a?(ActiveRecord::Base)}
            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

            Function parseFormattedString has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            Date.parseFormattedString = function (string) {
            
                var regexp = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})" + 
                    "( ([0-9]{1,2}):([0-9]{2})?" +
                    "?)?)?)?"; 
            Severity: Minor
            Found in public/javascripts/calendar_date_select/format_iso_date.js - 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 activity_title has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def activity_title(activity, plain = false, mobile = false)
                values = mobile ? { :user => (plain ? h(activity.user.short_name) : "<span class='user'>#{h activity.user.short_name}</span>") } :
                                  { :user => link_to_unless(plain, h(activity.user.name), activity.user) }
            
                case activity
            Severity: Minor
            Found in app/helpers/activities_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

            Function InsertHereFunc has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            var InsertHereFunc = function(evt){
              if (!InsertHere.enabled)
                return;
            
              var el = $(evt.target);
            Severity: Minor
            Found in app/javascripts/pages.js - 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
                authorize! :admin, @target
                if @target != current_user
                  user_or_email = params[:user_or_email]
                  role = params || Person::ROLES[:participant]
            Severity: Minor
            Found in app/controllers/api_v1/invitations_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 download has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def download
                head(:forbidden) and return unless @data.downloadable?(current_user)
            
                if Teambox.config.amazon_s3
                  redirect_to @data.processed_data.url
            Severity: Minor
            Found in app/controllers/teambox_datas_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 create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                # pass the project so target.project lookup can be skipped
                authorize! :comment, target, @current_project
            
                comment = target.comments.create_by_user current_user, params[:comment]
            Severity: Minor
            Found in app/controllers/comments_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

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

                if Array(options[:include]).include? :thread_comments
                  base[:first_comment] = first_comment.to_api_hash(options)  if first_comment
                  base[:recent_comments] = recent_comments.map{|c|c.to_api_hash(options)}
                elsif !Array(options[:include]).include?(:comments)
                  base[:first_comment_id] = first_comment.try(:id)
            Severity: Major
            Found in app/models/task/conversions.rb and 2 other locations - About 1 hr to fix
            app/models/conversation/conversions.rb on lines 35..41
            app/models/task_list/conversions.rb on lines 51..57

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

            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 3 locations. Consider refactoring.
            Open

                if Array(options[:include]).include? :thread_comments
                  base[:first_comment] = first_comment.to_api_hash(options)  if first_comment
                  base[:recent_comments] = recent_comments.map{|c|c.to_api_hash(options)}
                elsif !Array(options[:include]).include?(:comments)
                  base[:first_comment_id] = first_comment.try(:id)
            Severity: Major
            Found in app/models/task_list/conversions.rb and 2 other locations - About 1 hr to fix
            app/models/conversation/conversions.rb on lines 35..41
            app/models/task/conversions.rb on lines 54..60

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

            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