Showing 5 of 5 total issues

Class Controller has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Controller
    # Pio::FlowMod.new argument
    class FlowModAddOption
      def initialize(user_options)
        @user_options = user_options
Severity: Minor
Found in lib/trema/controller.rb - About 2 hrs to fix

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

  class Command
    def self.unix_domain_socket(name, check = false)
      path = File.expand_path(File.join(Phut.socket_dir, "#{name}.ctl"))
      if check && !FileTest.socket?(path)
        raise "Socket file #{path} does not exist."
Severity: Minor
Found in lib/trema/command.rb - About 2 hrs to fix

Method handle_openflow_message has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def handle_openflow_message(datapath_id)
      begin
        message = SWITCH.fetch(datapath_id).read
      rescue KeyError
        logger.debug "Switch #{datapath_id} is disconnected."
Severity: Minor
Found in lib/trema/controller.rb - About 1 hr to fix

Method start_phut has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def start_phut(config_file)
      return unless config_file
      system 'sudo -v'
      @phut = Phut::Parser.new(@controller.logger).parse(config_file)
      @phut_run_thread = Thread.start { @phut.run }
Severity: Minor
Found in lib/trema/command.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 killall has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def killall
      @controller.logger.debug 'Shutting down...' if @controller
      @controller.stop
      @controller_thread.kill if @controller_thread
      @phut_run_thread.kill if @phut_run_thread
Severity: Minor
Found in lib/trema/command.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