livinginthepast/fake_ftp

View on GitHub

Showing 5 of 6 total issues

Method start has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

    def start
      @started = true
      @server = ::TCPServer.new('127.0.0.1', port)
      @port = @server.addr[1]
      @thread = Thread.new do
Severity: Minor
Found in lib/fake_ftp/server.rb - About 6 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

Class Server has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Server
    attr_accessor :client, :command_state, :data_server, :passive_port
    attr_accessor :port, :store, :workdir

    alias path workdir
Severity: Minor
Found in lib/fake_ftp/server.rb - About 2 hrs to fix

    Method start has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def start
          @started = true
          @server = ::TCPServer.new('127.0.0.1', port)
          @port = @server.addr[1]
          @thread = Thread.new do
    Severity: Minor
    Found in lib/fake_ftp/server.rb - About 1 hr to fix

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

          private def load_command_instance(command)
            require "fake_ftp/server_commands/#{command}"
            FakeFtp::ServerCommands.constants.each do |const_name|
              next unless const_name.to_s.downcase == command
              return FakeFtp::ServerCommands.const_get(const_name).new
      Severity: Minor
      Found in lib/fake_ftp/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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def run(ctx, filename = '', *)
              ctx.respond_with('501 No filename given') if filename.empty?
      
              f = ctx.file(filename.to_s)
              return ctx.respond_with('550 File not found') if f.nil?
      Severity: Minor
      Found in lib/fake_ftp/server_commands/retr.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