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
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
- Read upRead up
- Exclude checks
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'
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
- Read upRead up
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
- Read upRead up
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
# -----------------------
Cyclomatic complexity for run is too high. [8/6] Open
def run
tmpbyte = 0;
@runner = true
- Read upRead up
- Exclude checks
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
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))
unexpected token tIDENTIFIER
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
amount_of_noise: noise,
- Exclude checks
unexpected token tLABEL
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
mid_gamma: parsed[7]
- Exclude checks
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
- Read upRead up
- Exclude checks
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],
- Exclude checks
unexpected token tLABEL
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
low_alpha: parsed[2],
- Exclude checks
unexpected token tLABEL
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
high_alpha: parsed[3],
- Exclude checks
unexpected token tLABEL
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
high_beta: parsed[5],
- Exclude checks
unexpected token tLABEL
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
low_gamma: parsed[6],
- Exclude checks
unexpected token tLABEL
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
theta: parsed[1],
- Exclude checks
unexpected token tRPAREN
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
)
- Exclude checks
unexpected token $end
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
- Exclude checks