dblock/slack-gamebot

View on GitHub

Showing 58 of 126 total issues

File bootstrap.js has 1587 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * Bootstrap v3.3.6 (http://getbootstrap.com)
 * Copyright 2011-2015 Twitter, Inc.
 * Licensed under the MIT license
 */
Severity: Major
Found in public/js/bootstrap.js - About 4 days to fix

    Class Team has 35 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Team
      field :gifs, type: Boolean, default: true
      field :api, type: Boolean, default: false
      field :aliases, type: Array, default: []
      field :dead_at, type: DateTime
    Severity: Minor
    Found in slack-gamebot/models/team.rb - About 4 hrs to fix

      Method find_by_slack_mention! has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.find_by_slack_mention!(client, user_name)
          team = client.owner
          slack_id = slack_mention?(user_name)
          user = if slack_id
                   team.users.where(user_id: slack_id).first
      Severity: Minor
      Found in slack-gamebot/models/user.rb - About 3 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 sort_order has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

            def sort_order(options = {})
              params[:sort] = options[:default_sort_order] unless params[:sort]
              return [] unless params[:sort]
      
              sort_order = params[:sort].to_s
      Severity: Minor
      Found in slack-gamebot/api/helpers/sort_helpers.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 set_nickname has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

              def set_nickname(client, data, user, v)
                target_user = user
                slack_mention = v.split.first if v
                if v && User.slack_mention?(slack_mention)
                  raise SlackGamebot::Error, "You're not a captain, sorry." unless user.captain?
      Severity: Minor
      Found in slack-gamebot/commands/set.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

      Class Challenge has 23 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Challenge
        include Mongoid::Document
        include Mongoid::Timestamps
      
        index(state: 1, channel: 1)
      Severity: Minor
      Found in slack-gamebot/models/challenge.rb - About 2 hrs to fix

        Function show has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          Tooltip.prototype.show = function () {
            var e = $.Event('show.bs.' + this.type)
        
            if (this.hasContent() && this.enabled) {
              this.$element.trigger(e)
        Severity: Major
        Found in public/js/bootstrap.js - About 2 hrs to fix

          Method find_create_or_update_by_slack_id! has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.find_create_or_update_by_slack_id!(client, slack_id)
              instance = User.where(team: client.owner, user_id: slack_id).first
              users_info = client.web_client.users_info(user: slack_id)
              instance_info = Hashie::Mash.new(users_info).user if users_info
              if users_info && instance
          Severity: Minor
          Found in slack-gamebot/models/user.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 paginate_by_cursor has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                def paginate_by_cursor(coll, &_block)
                  raise 'Both cursor and offset parameters are present, these are mutually exclusive.' if params.key?(:offset) && params.key?(:cursor)
          
                  results = { results: [], next: nil }
                  size = (params[:size] || 10).to_i
          Severity: Minor
          Found in slack-gamebot/api/helpers/cursor_helpers.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 slide has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            Carousel.prototype.slide = function (type, next) {
              var $active   = this.$element.find('.item.active')
              var $next     = next || this.getItemForDirection(type, $active)
              var isCycling = this.interval
              var direction = type == 'next' ? 'left' : 'right'
          Severity: Minor
          Found in public/js/bootstrap.js - About 1 hr to fix

            Method check has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.check(pair)
                pair_n = if pair.include?(':')
                           pair.split(':') if pair.include?(':')
                         elsif pair.include?('-')
                           pair.split('-')
            Severity: Minor
            Found in slack-gamebot/models/score.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 backdrop has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              Modal.prototype.backdrop = function (callback) {
                var that = this
                var animate = this.$element.hasClass('fade') ? 'fade' : ''
            
                if (this.isShown && this.options.backdrop) {
            Severity: Minor
            Found in public/js/bootstrap.js - About 1 hr to fix

              Function show has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                Modal.prototype.show = function (_relatedTarget) {
                  var that = this
                  var e    = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
              
                  this.$element.trigger(e)
              Severity: Minor
              Found in public/js/bootstrap.js - About 1 hr to fix

                Function activate has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  Tab.prototype.activate = function (element, container, callback) {
                    var $active    = container.find('> .active')
                    var transition = callback
                      && $.support.transition
                      && ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length)
                Severity: Minor
                Found in public/js/bootstrap.js - About 1 hr to fix

                  Function show has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    Collapse.prototype.show = function () {
                      if (this.transitioning || this.$element.hasClass('in')) return
                  
                      var activesData
                      var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing')
                  Severity: Minor
                  Found in public/js/bootstrap.js - About 1 hr to fix

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

                            def unset_nickname(client, data, user, v)
                              target_user = user
                              slack_mention = v.split.first if v
                              if User.slack_mention?(slack_mention)
                                raise SlackGamebot::Error, "You're not a captain, sorry." unless user.captain?
                    Severity: Minor
                    Found in slack-gamebot/commands/set.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_s has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def to_s
                        wins_s = "#{wins} win#{wins == 1 ? '' : 's'}"
                        losses_s = "#{losses} loss#{losses == 1 ? '' : 'es'}"
                        ties_s = "#{ties} tie#{ties == 1 ? '' : 's'}" if ties && ties > 0
                        elo_s = "elo: #{team_elo}"
                    Severity: Minor
                    Found in slack-gamebot/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 find_by_slack_mention! has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def self.find_by_slack_mention!(client, user_name)
                        team = client.owner
                        slack_id = slack_mention?(user_name)
                        user = if slack_id
                                 team.users.where(user_id: slack_id).first
                    Severity: Minor
                    Found in slack-gamebot/models/user.rb - About 1 hr to fix

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

                        Tooltip.prototype.applyPlacement = function (offset, placement) {
                          var $tip   = this.tip()
                          var width  = $tip[0].offsetWidth
                          var height = $tip[0].offsetHeight
                      
                      
                      Severity: Minor
                      Found in public/js/bootstrap.js - About 1 hr to fix

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

                          Tab.prototype.show = function () {
                            var $this    = this.element
                            var $ul      = $this.closest('ul:not(.dropdown-menu)')
                            var selector = $this.data('target')
                        
                        
                        Severity: Minor
                        Found in public/js/bootstrap.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language