lib/cw/read.rb

Summary

Maintainability
C
1 day
Test Coverage

Method decode_signal has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def decode_signal
      if(@state[FILTERED])
        @state[FILTERED] = false
        @need_space = true
        #dbg_print "wpm #{@wpm.to_s}\nhigh period: #{@high[PERIOD]}\nhigh avg: #{@high[AVG]}"
Severity: Minor
Found in lib/cw/read.rb - About 3 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 Read has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Read

    def n ; N ; end
    def k ; (0.5 + ((n * @tone / @sample_rate))).to_i ; end
    def w ; ((2 * Math::PI) / n) * k ; end
Severity: Minor
Found in lib/cw/read.rb - About 2 hrs to fix

    Method initialize has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def initialize(filename)
          @tone = TONE
          @mag_max = 0
          @mag_min = 999999999
          @sample_rate = SAMPLE_RATE
    Severity: Minor
    Found in lib/cw/read.rb - About 1 hr to fix

      Method calc_filtered_state has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def calc_filtered_state
            if real_state_change?
              reset_noise_blanker
            end
      
      
      Severity: Minor
      Found in lib/cw/read.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 input has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def input
            dly = @n_delay_ms
            open_sound_device
            nval = @n_val
            buf = @buf_in
      Severity: Minor
      Found in lib/cw/read.rb - About 1 hr to fix

        Method decode_signal has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def decode_signal
              if(@state[FILTERED])
                @state[FILTERED] = false
                @need_space = true
                #dbg_print "wpm #{@wpm.to_s}\nhigh period: #{@high[PERIOD]}\nhigh avg: #{@high[AVG]}"
        Severity: Minor
        Found in lib/cw/read.rb - About 1 hr to fix

          There are no issues that match your filters.

          Category
          Status