wconrad/ftpd

View on GitHub

Showing 16 of 18 total issues

Class Session has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Session

    include Error
    include ListPath

Severity: Minor
Found in lib/ftpd/session.rb - About 3 hrs to fix

    Method read_and_execute_commands has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def read_and_execute_commands
          catch :done do
            begin
              reply "220 #{server_name_and_version}"
              loop do
    Severity: Minor
    Found in lib/ftpd/command_loop.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 option_parser has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def option_parser
          OptionParser.new do |op|
            op.on('-p', '--port N', Integer, 'Bind to a specific port') do |t|
              @port = t
            end
    Severity: Minor
    Found in examples/example.rb - About 1 hr to fix

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

          def make_server_thread
            Thread.new do
              Thread.abort_on_exception = true
              loop do
                begin
      Severity: Minor
      Found in lib/ftpd/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

      Method standard_command_handlers has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.standard_command_handlers
            [
              CmdAbor,
              CmdAllo,
              CmdAppe,
      Severity: Minor
      Found in lib/ftpd/command_handler_factory.rb - About 1 hr to fix

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

            def cmd_port(argument)
              ensure_logged_in
              ensure_not_epsv_all
              pieces = argument.split(/,/)
              syntax_error unless pieces.size == 6
        Severity: Minor
        Found in lib/ftpd/cmd_port.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def initialize(user, password, account, data_dir, read_only)
        Severity: Minor
        Found in examples/example.rb - About 35 mins to fix

          Method triad has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  def triad(read_bit, write_bit, execute_bit, special_bit, special_letters)
          Severity: Minor
          Found in lib/ftpd/list_format/ls.rb - About 35 mins to fix

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

                def converted_chunk(io)
                  chunk = io.read(CHUNK_SIZE)
                  return unless chunk
                  if data_type == 'A'
                    next_char = io.getc
            Severity: Minor
            Found in lib/ftpd/stream.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 cmd_stru has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def cmd_stru(argument)
                  syntax_error unless argument
                  ensure_logged_in
                  name, implemented = FILE_STRUCTURES[argument]
                  error "Invalid structure code", 504 unless name
            Severity: Minor
            Found in lib/ftpd/cmd_stru.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 stop_track has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def stop_track(socket)
                  @mutex.synchronize do
                    ip = @socket_ips.delete(socket.object_id)
                    break unless ip
                    if (@connections[ip] -= 1) == 0
            Severity: Minor
            Found in lib/ftpd/connection_tracker.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 cmd_prot has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def cmd_prot(level_arg)
                  level_code = level_arg.upcase
                  unless protection_buffer_size_set
                    error "PROT must be preceded by PBSZ", 503
                  end
            Severity: Minor
            Found in lib/ftpd/cmd_prot.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 cmd_epsv has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def cmd_epsv(argument)
                  ensure_logged_in
                  if data_server
                    reply "200 Already in passive mode"
                  else
            Severity: Minor
            Found in lib/ftpd/cmd_epsv.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 cmd_pbsz has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def cmd_pbsz(buffer_size)
                  ensure_tls_supported
                  syntax_error unless buffer_size =~ /^\d+$/
                  buffer_size = buffer_size.to_i
                  unless socket.encrypted?
            Severity: Minor
            Found in lib/ftpd/cmd_pbsz.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 cmd_mode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def cmd_mode(argument)
                  syntax_error unless argument
                  ensure_logged_in
                  name, implemented = TRANSMISSION_MODES[argument]
                  error "Invalid mode code", 504 unless name
            Severity: Minor
            Found in lib/ftpd/cmd_mode.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 open_data_connection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def open_data_connection(path_to_advertise = nil, &block)
                  send_start_of_data_connection_reply(path_to_advertise)
                  if data_server
                    if encrypt_data?
                      open_passive_tls_data_connection(&block)
            Severity: Minor
            Found in lib/ftpd/data_connection_helper.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