wconrad/ftpd

View on GitHub

Showing 18 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 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 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

            Similar blocks of code found in 2 locations. 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 and 1 other location - About 25 mins to fix
            lib/ftpd/cmd_mode.rb on lines 9..16

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

            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

                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 and 1 other location - About 25 mins to fix
            lib/ftpd/cmd_stru.rb on lines 9..16

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

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

            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_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_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 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

            Severity
            Category
            Status
            Source
            Language