hendolim/countonanon

View on GitHub

Showing 83 of 83 total issues

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

                v = partial.length === 0
                    ? '[]'
                    : gap
                    ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
                    : '[' + partial.join(',') + ']';
Severity: Major
Found in faye-1.1.2/lib/faye-browser.js and 1 other location - About 2 hrs to fix
faye-1.1.2/lib/faye-browser.js on lines 2208..2212

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

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

            v = partial.length === 0
                ? '{}'
                : gap
                ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
                : '{' + partial.join(',') + '}';
Severity: Major
Found in faye-1.1.2/lib/faye-browser.js and 1 other location - About 2 hrs to fix
faye-1.1.2/lib/faye-browser.js on lines 2169..2173

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

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

    Growl.prototype.present = function(callback) {
      var $growl;
      $growl = this.$growl();
      this.bind($growl);
      return this.animate($growl, this.settings.namespace + "-incoming", 'out', callback);
Severity: Major
Found in app/assets/javascripts/jquery.growl.js and 1 other location - About 2 hrs to fix
app/assets/javascripts/jquery.growl.js on lines 144..149

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

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

    Growl.prototype.dismiss = function(callback) {
      var $growl;
      $growl = this.$growl();
      this.unbind($growl);
      return this.animate($growl, this.settings.namespace + "-outgoing", 'in', callback);
Severity: Major
Found in app/assets/javascripts/jquery.growl.js and 1 other location - About 2 hrs to fix
app/assets/javascripts/jquery.growl.js on lines 137..142

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

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

    def connect(message, local = false, &callback)
      response        = make_response(message)
      client_id       = message['clientId']
      connection_type = message['connectionType']

Severity: Minor
Found in faye-1.1.2/lib/faye/protocol/server.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 get has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def get(dispatcher, allowed, disabled, &callback)
        endpoint = dispatcher.endpoint

        select = lambda do |(conn_type, klass), resume|
          conn_endpoint = dispatcher.endpoint_for(conn_type)
Severity: Minor
Found in faye-1.1.2/lib/faye/transport/transport.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 connect has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def connect
      @state ||= UNCONNECTED
      return unless @state == UNCONNECTED
      @state = CONNECTING

Severity: Minor
Found in faye-1.1.2/lib/faye/transport/web_socket.rb - About 2 hrs to fix

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

        def call(env)
          filename = File.basename(env['PATH_INFO'])
          filename = @path_map[filename] || filename
    
          cache = @index[filename] ||= {}
    Severity: Minor
    Found in faye-1.1.2/lib/faye/adapters/static_server.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 connect has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      connect: function() {
        if (Faye.Transport.WebSocket._unloaded) return;
    
        this._state = this._state || this.UNCONNECTED;
        if (this._state !== this.UNCONNECTED) return;
    Severity: Minor
    Found in faye-1.1.2/lib/faye-browser.js - About 1 hr to fix

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

        def create
          respond_to do |format|
            @message = @conversation.messages.new(message_params)
            @messages = @conversation.messages
            if @messages.length==0
      Severity: Minor
      Found in app/controllers/messages_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 emit has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      EventEmitter.prototype.emit = function(type) {
        // If there is no 'error' event listener then throw.
        if (type === 'error') {
          if (!this._events || !this._events.error ||
              (isArray(this._events.error) && !this._events.error.length))
      Severity: Minor
      Found in faye-1.1.2/lib/faye-browser.js - About 1 hr to fix

        Method handle_request has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def handle_request(request)
              unless json_msg = message_from_request(request)
                error 'Received request with no message: ?', format_request(request)
                return [400, TYPE_TEXT, ['Bad request']]
              end
        Severity: Minor
        Found in faye-1.1.2/lib/faye/adapters/rack_adapter.rb - About 1 hr to fix

          Function request has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            request: function(messages) {
              var xhrClass = Faye.ENV.XDomainRequest ? XDomainRequest : XMLHttpRequest,
                  xhr      = new xhrClass(),
                  id       = ++Faye.Transport.CORS._id,
                  headers  = this._dispatcher.headers,
          Severity: Minor
          Found in faye-1.1.2/lib/faye-browser.js - About 1 hr to fix

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

              parse: function(url) {
                if (typeof url !== 'string') return url;
                var uri = {}, parts, query, pairs, i, n, data;
            
                var consume = function(name, pattern) {
            Severity: Minor
            Found in faye-1.1.2/lib/faye-browser.js - About 1 hr to fix

              Method subscribe has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def subscribe(channel, force = false, &block)
                    if Array === channel
                      return channel.map { |c| subscribe(c, force, &block) }
                    end
              
              
              Severity: Minor
              Found in faye-1.1.2/lib/faye/protocol/client.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 async_each has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.async_each(list, iterator, callback)
                  n       = list.size
                  i       = -1
                  calls   = 0
                  looping = false
              Severity: Minor
              Found in faye-1.1.2/lib/faye.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 parse has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      JSON.parse = function (text, reviver) {
              
              // The parse method takes a text and an optional reviver function, and returns
              // a JavaScript value if the text is a valid JSON text.
              
              
              Severity: Minor
              Found in faye-1.1.2/lib/faye-browser.js - About 1 hr to fix

                Function request has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  request: function(messages) {
                    var href = this.endpoint.href,
                        xhr  = Faye.ENV.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest(),
                        self = this;
                
                
                Severity: Minor
                Found in faye-1.1.2/lib/faye-browser.js - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                        if ((element    && element    !== register._element)   ||
                            (eventName  && eventName  !== register._type)      ||
                            (callback   && callback   !== register._callback)  ||
                            (context      && context      !== register._context))
                          continue;
                  Severity: Critical
                  Found in faye-1.1.2/lib/faye-browser.js - About 1 hr to fix

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

                        def advize(response, connection_type)
                          return unless [Channel::HANDSHAKE, Channel::CONNECT].include?(response['channel'])
                    
                          if connection_type == 'eventsource'
                            interval = (@engine.timeout * 1000).floor
                    Severity: Minor
                    Found in faye-1.1.2/lib/faye/protocol/server.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