dblock/slack-sup

View on GitHub

Showing 57 of 114 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

    File set.rb has 402 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module SlackSup
      module Commands
        class Set < SlackRubyBot::Commands::Base
          include SlackSup::Commands::Mixins::Subscribe
    
    
    Severity: Minor
    Found in slack-sup/commands/set.rb - About 5 hrs to fix

      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-sup/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 team_data_access_message has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

              def team_data_access_message(user, updated_api = false, updated_token = false)
                if user.team.api? && user.team_admin? && user.team.api_token
                  "Team data access via the API is #{updated_api ? 'now ' : nil}on with a#{updated_token ? ' new' : 'n'} access token `#{user.team.api_token}`."
                elsif user.team.api? && !user.team_admin? && user.team.api_token
                  "Team data access via the API is #{updated_api ? 'now ' : nil}on with a#{updated_token ? ' new' : 'n'} access token visible to admins."
      Severity: Minor
      Found in slack-sup/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 Set has 23 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Set < SlackRubyBot::Commands::Base
            include SlackSup::Commands::Mixins::Subscribe
      
            class << self
              def set_opt_in(client, team, data, user, v = nil)
      Severity: Minor
      Found in slack-sup/commands/set.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

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

                    def set_time(client, team, data, user, v = nil)
                      if user.team_admin? && v
                        # attempt to parse a timezone right to left
                        z = []
                        tz = nil
            Severity: Minor
            Found in slack-sup/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 set_odd has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                    def set_odd(client, team, data, user, v = nil)
                      if user.team_admin? && !v.nil?
                        team.update_attributes!(sup_odd: v.to_b)
                        client.say(channel: data.channel, text: "Team S'Up now connects groups of #{team.sup_odd ? 'max ' : ''}#{team.sup_size} people.")
                      elsif !v.nil?
            Severity: Minor
            Found in slack-sup/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

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

                            def set(client, team, data, user, k, v)
                              case k
                              when 'opt' then
                                set_opt_in client, team, data, user, v
                              when 'api' then
                    Severity: Minor
                    Found in slack-sup/commands/set.rb - About 1 hr to fix

                      Function error has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                      SlackSup.error = function(xhr) {
                        var message;
                        if (xhr.responseText) {
                          var rc = JSON.parse(xhr.responseText);
                          if (rc && rc.error) {
                      Severity: Minor
                      Found in public/js/sup.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

                      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

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

                                  def set_api_token(client, team, data, user)
                                    if !team.api?
                                      set_api(client, team, data, user)
                                    elsif user.team_admin? && !team.api_token
                                      team.update_attributes!(api_token: SecureRandom.hex)
                          Severity: Minor
                          Found in slack-sup/commands/set.rb - About 1 hr to fix

                            Function checkPosition has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              Affix.prototype.checkPosition = function () {
                                if (!this.$element.is(':visible')) return
                            
                                var height       = this.$element.height()
                                var offset       = this.options.offset
                            Severity: Minor
                            Found in public/js/bootstrap.js - About 1 hr to fix

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

                                      def export!(root, name = self.class.name, presenter = nil, coll = nil)
                                        presenter ||= Object.const_get("Api::Presenters::#{self.class.name}Presenter")
                                        keys = presenter.representable_attrs.keys - ['links']
                                        data = coll || Array(self)
                                        FileUtils.makedirs(root)
                              Severity: Minor
                              Found in slack-sup/models/mixins/export.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

                              Severity
                              Category
                              Status
                              Source
                              Language