hendolim/countonanon

View on GitHub

Showing 83 of 83 total issues

Avoid deeply nested control flow statements.
Open

                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
Severity: Major
Found in faye-1.1.2/lib/faye-browser.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                                if (v !== undefined) {
                                    value[k] = v;
                                } else {
                                    delete value[k];
                                }
    Severity: Major
    Found in faye-1.1.2/lib/faye-browser.js - About 45 mins to fix

      Method send_message has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def send_message(message, options, &callback)
            message['id'] = generate_message_id
      
            timeout = [nil, 0].include?(@advice['timeout']) ?
                      1.2 * @dispatcher.retry :
      Severity: Minor
      Found in faye-1.1.2/lib/faye/protocol/client.rb - About 45 mins 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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def connect(&block)
            return if @advice['reconnect'] == NONE or
                      @state == DISCONNECTED
      
            return handshake { connect(&block) } if @state == UNCONNECTED
      Severity: Minor
      Found in faye-1.1.2/lib/faye/protocol/client.rb - About 45 mins 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

      Avoid deeply nested control flow statements.
      Open

                              if (v) {
                                  partial.push(quote(k) + (gap ? ': ' : ':') + v);
                              }
      Severity: Major
      Found in faye-1.1.2/lib/faye-browser.js - About 45 mins to fix

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

            for (var i = 0, n = messages.length; i < n; i++) this._pending.add(messages[i]);
        Severity: Minor
        Found in faye-1.1.2/lib/faye-browser.js and 2 other locations - About 40 mins to fix
        faye-1.1.2/lib/faye-browser.js on lines 1739..1740
        faye-1.1.2/lib/faye-browser.js on lines 1749..1750

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

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

            for (var i = 0, n = replies.length; i < n; i++)
              this._dispatcher.handleResponse(replies[i]);
        Severity: Minor
        Found in faye-1.1.2/lib/faye-browser.js and 2 other locations - About 40 mins to fix
        faye-1.1.2/lib/faye-browser.js on lines 1749..1750
        faye-1.1.2/lib/faye-browser.js on lines 2366..2366

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

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

            for (var i = 0, n = messages.length; i < n; i++)
              this._dispatcher.handleError(messages[i]);
        Severity: Minor
        Found in faye-1.1.2/lib/faye-browser.js and 2 other locations - About 40 mins to fix
        faye-1.1.2/lib/faye-browser.js on lines 1739..1740
        faye-1.1.2/lib/faye-browser.js on lines 2366..2366

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

        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 pipeThroughExtensions has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          pipeThroughExtensions: function(stage, message, request, callback, context) {
        Severity: Minor
        Found in faye-1.1.2/lib/faye-browser.js - About 35 mins to fix

          Function get has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            get: function(dispatcher, allowed, disabled, callback, context) {
          Severity: Minor
          Found in faye-1.1.2/lib/faye-browser.js - About 35 mins to fix

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

              isService: function(name) {
                var segments = this.parse(name);
                return segments ? (segments[0] === this.SERVICE) : null;
              },
            Severity: Minor
            Found in faye-1.1.2/lib/faye-browser.js and 1 other location - About 35 mins to fix
            faye-1.1.2/lib/faye-browser.js on lines 997..1000

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

            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

              isMeta: function(name) {
                var segments = this.parse(name);
                return segments ? (segments[0] === this.META) : null;
              },
            Severity: Minor
            Found in faye-1.1.2/lib/faye-browser.js and 1 other location - About 35 mins to fix
            faye-1.1.2/lib/faye-browser.js on lines 1002..1005

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

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

              def index
                @messages = @conversation.messages
            
                if @messages.length==0
                  @last_user = nil
            Severity: Minor
            Found in app/controllers/messages_controller.rb - About 35 mins 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 online? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def online?
                if current_sign_in_at.present? 
                  online_status = last_sign_out_at.present? ? current_sign_in_at > last_sign_out_at : true
                  if (online_status)
                    online_status = updated_at > 1.minutes.ago
            Severity: Minor
            Found in app/models/user.rb - About 35 mins 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 handshake has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def handshake(message, local = false, &callback)
                  response = make_response(message)
                  response['version'] = BAYEUX_VERSION
            
                  response['error'] = Error.parameter_missing('version') if message['version'].nil?
            Severity: Minor
            Found in faye-1.1.2/lib/faye/protocol/server.rb - About 35 mins 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

            Avoid too many return statements within this function.
            Open

                return true;
            Severity: Major
            Found in faye-1.1.2/lib/faye-browser.js - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return handle_eventsource(request) if Faye::EventSource.eventsource?(env)
              Severity: Major
              Found in faye-1.1.2/lib/faye/adapters/rack_adapter.rb - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return false;
                Severity: Major
                Found in faye-1.1.2/lib/faye-browser.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      if (this._connectRequest) return;
                  Severity: Major
                  Found in faye-1.1.2/lib/faye-browser.js - About 30 mins to fix

                    Method initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def initialize(app = nil, options = nil, &block)
                          @app     = app if app.respond_to?(:call)
                          @options = [app, options].grep(Hash).first || {}
                    
                          ::WebSocket::Driver.validate_options(@options, [:engine, :mount, :ping, :timeout, :extensions, :websocket_extensions])
                    Severity: Minor
                    Found in faye-1.1.2/lib/faye/adapters/rack_adapter.rb - About 25 mins 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