hendolim/countonanon

View on GitHub

Showing 57 of 83 total issues

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

      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

          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

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

                      def handle(message, local = false, &callback)
                        return callback.call([]) if !message
                        info('Handling message: ? (local: ?)', message, local)
                  
                        channel_name = message['channel']
                  Severity: Minor
                  Found in faye-1.1.2/lib/faye/protocol/server.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

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

                        def flush_connection(client_id, close = true)
                          return unless client_id
                          debug('Flushing connection for ?', client_id)
                          return unless conn = connection(client_id, false)
                          conn.socket = nil unless close
                  Severity: Minor
                  Found in faye-1.1.2/lib/faye/engines/proxy.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

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

                      def send_envelope(envelope)
                        return unless @transport
                        return if envelope.request or envelope.timer
                  
                        message   = envelope.message
                  Severity: Minor
                  Found in faye-1.1.2/lib/faye/protocol/dispatcher.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