crewmate/crewmate

View on GitHub

Showing 358 of 358 total issues

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

    } else {
        $$('.cal_wd' + this.weekends[0] + ', .cal_wd' + this.weekends[1]).each(function(e) {e.hide();})
      $('calendar').addClassName('calendar5')
    }
Severity: Major
Found in app/javascripts/hours.js and 1 other location - About 2 hrs to fix
app/javascripts/hours.js on lines 245..248

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

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 toggle has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    toggle: function(new_record, header_id, link_id, form_id) {
        var header = $(header_id);
        var link = $(link_id);
        var form = $(form_id);
        
Severity: Minor
Found in app/javascripts/toggleform.js - About 2 hrs 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 16 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    logout_keeping_session!
    @user = User.new(params[:user])

    @user.confirmed_user = ((@invitation && @invitation.email == @user.email) or
Severity: Minor
Found in app/controllers/users_controller.rb - About 2 hrs 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 52 lines of code (exceeds 25 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: Major
Found in app/helpers/activities_helper.rb - About 2 hrs to fix

    File task_lists_controller.rb has 253 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class TaskListsController < ApplicationController
      around_filter :set_time_zone, :only => [:index, :show, :gantt_view]
      before_filter :load_task_list, :only => [:edit,:update,:show,:destroy,:watch,:unwatch,:archive,:unarchive]
      before_filter :load_task_lists, :only => [:index, :reorder]
      before_filter :set_page_title
    Severity: Minor
    Found in app/controllers/task_lists_controller.rb - About 2 hrs to fix

      Function initButtonsDiv has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        initButtonsDiv: function()
        {
          var buttons_div = this.buttons_div;
          if (this.options.get("time"))
          {
      Severity: Minor
      Found in public/javascripts/calendar_date_select/calendar_date_select.js - About 1 hr to fix

        Method to_xml has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def to_xml(options = {})
            options[:indent] ||= 2
            xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
            xml.instruct! unless options[:skip_instruct]
            xml.comment :id => id do
        Severity: Minor
        Found in app/models/comment/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 hours_js has a Cognitive Complexity of 15 (exceeds 5 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

        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 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def download
            head(:not_found) and return if (upload = Upload.find_by_id(params[:id])).nil?
            head(:forbidden) and return unless upload.downloadable?(current_user)
        
            if !!Teambox.config.amazon_s3
        Severity: Minor
        Found in app/controllers/uploads_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 process_incoming has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def process_incoming(email)
            raise MissingInfo, "Invalid mail body" if email.body.blank?
        
            from = Array(email.from).first
            raise MissingInfo, "Invalid From field" if from.nil?
        Severity: Minor
        Found in app/models/emailer/incoming.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

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

        document.on('click', '#show_gantt_chart_link', function(e,el){
            e.stop();
            Banner.deactivate_tabs();
            Banner.hide_banner_items();
            Banner.show_banner("gantt_banner");
        Severity: Major
        Found in app/javascripts/banner.js and 1 other location - About 1 hr to fix
        app/javascripts/banner.js on lines 17..23

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

        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

        document.on('click', '#show_calendar_link', function(e,el){
            e.stop();
            Banner.deactivate_tabs();
            Banner.hide_banner_items();
            Banner.show_banner("upcoming_events_banner");
        Severity: Major
        Found in app/javascripts/banner.js and 1 other location - About 1 hr to fix
        app/javascripts/banner.js on lines 25..31

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

        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 hsv2rgb has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          this.hsv2rgb = function (h, s, v) {
            var r, g, b;
            if ( s == 0 ) {
              r = v * 255;
              g = v * 255;
        Severity: Minor
        Found in app/javascripts/yahoo.color.js - About 1 hr to fix

          Method load_example_data has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def load_example_data
                @apiman = find_or_create_example_user('API Man', 'example_api_user')
                @project = @apiman.projects.first
                @organization = @apiman.organizations.first
                if @project.nil?
          Severity: Minor
          Found in app/controllers/apidocs_controller.rb - About 1 hr to fix

            Method to_xml has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              def to_xml(options = {})
                options[:indent] ||= 2
                xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
                xml.instruct! unless options[:skip_instruct]
                xml.task_list :id => id do
            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 create has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                authorize! :admin, @invite_target
                if params[:invitation]
                  user_or_email = params[:invitation][:user_or_email]
                  params[:invitation][:role] ||= Person::ROLES[:participant]
            Severity: Minor
            Found in app/controllers/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 convert_to_task has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              def convert_to_task
                authorize! :update, @conversation
            
                @conversation.attributes = params[:conversation]
                @conversation.updating_user = current_user
            Severity: Minor
            Found in app/controllers/conversations_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 14 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                authorize! :converse, @current_project
                @conversation = @current_project.conversations.new_by_user(current_user, params[:conversation])
            
                if @conversation.save
            Severity: Minor
            Found in app/controllers/conversations_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 updateCounts has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              updateCounts: function(due_only) {
                if (Filter.assigned_options == null && Filter.count_due_date == null)
                  Filter.init();
            
                var el = $("filter_assigned");
            Severity: Minor
            Found in app/javascripts/filter.js - About 1 hr to fix

              Method update_from_pivotal_tracker has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def update_from_pivotal_tracker(author, activity)
                  story = activity[:stories][:story]
                  author_name = activity[:author]
                  self.updating_user = author || self.user
              
              
              Severity: Minor
              Found in app/models/task.rb - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language