piotrmurach/tty-screen

View on GitHub

Showing 7 of 7 total issues

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

    def size_from_io_console(verbose: false)
      return unless output.tty?

      require "io/console" unless IO.method_defined?(:winsize)
      return unless output.respond_to?(:winsize)
Severity: Minor
Found in lib/tty/screen.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 size_from_readline has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def size_from_readline(verbose: false)
      return unless output.tty?

      require "readline" unless defined?(::Readline)
      return unless ::Readline.respond_to?(:get_screen_size)
Severity: Minor
Found in lib/tty/screen.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 size_from_win_api has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def size_from_win_api(verbose: false)
        require "fiddle" unless defined?(Fiddle)

        kernel32 = Fiddle::Handle.new("kernel32")
        get_std_handle = Fiddle::Function.new(
Severity: Minor
Found in lib/tty/screen.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 size_from_java has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def size_from_java(verbose: false)
        require "java"

        java_import "jline.TerminalFactory"
        terminal = TerminalFactory.get
Severity: Minor
Found in lib/tty/screen.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 size_from_ioctl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def size_from_ioctl
        buffer = Array.new(TIOCGWINSZ_BUF_LEN, 0).pack(TIOCGWINSZ_BUF_FMT)

        if ioctl?(TIOCGWINSZ, buffer) ||
           ioctl?(TIOCGWINSZ_PPC, buffer) ||
Severity: Minor
Found in lib/tty/screen.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 size_from_tput has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def size_from_tput
      return unless output.tty? && command_exist?("tput")

      lines = run_command("tput", "lines")
      return unless lines
Severity: Minor
Found in lib/tty/screen.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 size_from_stty has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def size_from_stty
      return unless output.tty? && command_exist?("stty")

      out = run_command("stty", "size")
      return unless out
Severity: Minor
Found in lib/tty/screen.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