heckpsi-lab/em-midori

View on GitHub

Showing 12 of 15 total issues

Class API has 37 methods (exceeds 20 allowed). Consider refactoring.
Open

class Midori::API
  class << self
     # @!attribute routes
     #   @return [Hash] merged routes defined in the instance
     # @!attribute scope_middlewares
Severity: Minor
Found in lib/midori/api.rb - About 4 hrs to fix

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

      def receive(request, connection = nil)
        @routes[request.method].each do |route|
          params = route.path.params(request.path)
          next unless params # Skip if not matched
          request.params = params
    Severity: Minor
    Found in lib/midori/api_engine.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 receive has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def receive(request, connection = nil)
        @routes[request.method].each do |route|
          params = route.path.params(request.path)
          next unless params # Skip if not matched
          request.params = params
    Severity: Minor
    Found in lib/midori/api_engine.rb - About 1 hr to fix

      Method initialize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def initialize
          @header = HTTPHeader.new
          @parsed = false
          @body_parsed = false
          @is_websocket = false
      Severity: Minor
      Found in lib/midori/request.rb - About 1 hr to fix

        Method send has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def send(msg)
            output = []
            payload_length = []
            if msg.size < 126
              payload_length << msg.size
        Severity: Minor
        Found in lib/midori/websocket.rb - About 1 hr to fix

          Method parse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def parse(data)
              # Call parser if header not parsed
              if @parsed
                @body += data
              else
          Severity: Minor
          Found in lib/midori/request.rb - About 55 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 receive_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def receive_data(socket)
              begin
                @request.ip, @request.port = @peer_addr
                if @request.parsed? && !(@request.body_parsed?)
                  data = socket.read @request.body.bytesize - @request.header['Content-Length']
          Severity: Minor
          Found in lib/midori/server.rb - About 55 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 middleware_exec has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            private def middleware_exec(middlewares, clean_room, request, response=nil)
              result = response.nil? ? request : response
              middlewares.each do |middleware|
                if response.nil?
                  result = Midori::Sandbox.run(
          Severity: Minor
          Found in lib/midori/api_engine.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 send has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def send(msg)
              output = []
              payload_length = []
              if msg.size < 126
                payload_length << msg.size
          Severity: Minor
          Found in lib/midori/websocket.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def initialize
              @header = HTTPHeader.new
              @parsed = false
              @body_parsed = false
              @is_websocket = false
          Severity: Minor
          Found in lib/midori/request.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 listen has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def listen
              Fiber.schedule do
                until @socket.closed?
                  receive_data(@socket)
                  if !@buffer.empty?
          Severity: Minor
          Found in lib/midori/connection.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 set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def set(option, value = (not_set = true), read_only = false)
              raise ArgumentError if not_set
          
              setter = proc { |val| set option, val }
              getter = proc { value }
          Severity: Minor
          Found in lib/midori/core_ext/configurable.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