whotwagner/mindwave

View on GitHub

Showing 22 of 22 total issues

Method parse_payload has 101 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def parse_payload(payload)
    if not payload.instance_of?Array or payload.nil? or payload.length < 2
        raise "Invalid Argument"
    end

Severity: Major
Found in lib/mindwave.rb - About 4 hrs to fix

    Cyclomatic complexity for parse_payload is too high. [25/6]
    Open

    def parse_payload(payload)
        if not payload.instance_of?Array or payload.nil? or payload.length < 2
            raise "Invalid Argument"
        end
    
    
    Severity: Minor
    Found in lib/mindwave.rb by rubocop

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    File mindwave.rb has 297 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "mindwave/version"
    
    require 'serialport' 
    require 'bindata'
    require 'logger'
    Severity: Minor
    Found in lib/mindwave.rb - About 3 hrs to fix

      Method parse_payload has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      def parse_payload(payload)
          if not payload.instance_of?Array or payload.nil? or payload.length < 2
              raise "Invalid Argument"
          end
      
      
      Severity: Minor
      Found in lib/mindwave.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 run has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      def run
      
              tmpbyte = 0;
          @runner = true
      
      
      Severity: Minor
      Found in lib/mindwave.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

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

      class Headset
      # -----------------------
      # :section: Request Codes
      # -----------------------
      
      
      Severity: Minor
      Found in lib/mindwave.rb - About 2 hrs to fix

        Cyclomatic complexity for run is too high. [8/6]
        Open

        def run
        
                tmpbyte = 0;
            @runner = true
        
        
        Severity: Minor
        Found in lib/mindwave.rb by rubocop

        This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

        An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

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

        def run
        
                tmpbyte = 0;
            @runner = true
        
        
        Severity: Minor
        Found in lib/mindwave.rb - About 1 hr to fix

          Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def initialize(headsetid=nil,device='/dev/ttyUSB0', connectserial=true,rate=115200, log=Logger.new(STDOUT))
          Severity: Minor
          Found in lib/mindwave.rb - About 35 mins to fix

            unexpected token tIDENTIFIER (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
            Open

                                          amount_of_noise:          noise,
            Severity: Minor
            Found in examples/asicwaves.rb by rubocop

            unexpected token tLABEL (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
            Open

                                          mid_gamma:                parsed[7]
            Severity: Minor
            Found in examples/asicwaves.rb by rubocop

            Put one space between the method name and the first argument.
            Open

                if not payload.instance_of?Array or payload.nil? or payload.length < 2
            Severity: Minor
            Found in lib/mindwave.rb by rubocop

            Checks that exactly one space is used between a method name and the first argument for method calls without parentheses.

            Alternatively, extra spaces can be added to align the argument with something on a preceding or following line, if the AllowForAlignment config parameter is true.

            Example:

            # bad
            something  x
            something   y, z
            something'hello'
            
            # good
            something x
            something y, z
            something 'hello'

            unexpected token tLABEL (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
            Open

                                          low_beta:                 parsed[4],
            Severity: Minor
            Found in examples/asicwaves.rb by rubocop

            unexpected token tLABEL (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
            Open

                                          low_alpha:                parsed[2],
            Severity: Minor
            Found in examples/asicwaves.rb by rubocop

            unexpected token tLABEL (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
            Open

                                          high_alpha:               parsed[3],
            Severity: Minor
            Found in examples/asicwaves.rb by rubocop

            unexpected token tLABEL (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
            Open

                                          high_beta:                parsed[5],
            Severity: Minor
            Found in examples/asicwaves.rb by rubocop

            unexpected token tLABEL (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
            Open

                                          low_gamma:                parsed[6],
            Severity: Minor
            Found in examples/asicwaves.rb by rubocop

            unexpected token tLABEL (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
            Open

                                          theta:                    parsed[1],
            Severity: Minor
            Found in examples/asicwaves.rb by rubocop

            unexpected token tRPAREN (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
            Open

                                          )
            Severity: Minor
            Found in examples/asicwaves.rb by rubocop

            unexpected token $end (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
            Open

            Severity: Minor
            Found in examples/asicwaves.rb by rubocop
            Severity
            Category
            Status
            Source
            Language