Showing 19 of 47 total issues
Function hid
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
export const hid = async (toy: SpheroMini) => {
let calibrating = false;
let offset = 0;
let stopped = false;
let heading: number;
- 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
Function cmdPlay
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
const cmdPlay = (toy: SpheroMini) => {
let pressTimeout: NodeJS.Timer;
let heading = 0;
let currentSpeed = 0;
let speed = 150;
- 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
Function cmdPlay
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
const cmdPlay = (toy: SpheroMini) => {
let pressTimeout: NodeJS.Timer;
let heading = 0;
let currentSpeed = 0;
let speed = 150;
Core
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
export class Core {
// Override in child class to get right percent
protected maxVoltage = 0;
protected minVoltage = 1;
protected apiVersion: APIVersion = APIVersion.V2;
Function factory
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
export function factory(
callback: (err: string, response?: ICommandWithRaw) => void
) {
let msg: number[] = [];
let checksum = 0;
- 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
Function factory
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function factory(
callback: (err: string, response?: ICommandWithRaw) => void
) {
let msg: number[] = [];
let checksum = 0;
Function handle
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
const handle = async (key = '', symbol: { name?: string } = {}) => {
cancelPress();
if (symbol.name === 'up') {
heading = 0;
currentSpeed = speed;
Function calculateDomeAngle
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
private calculateDomeAngle(angle: number) {
const result = new Uint8Array(2);
switch (angle) {
case -1:
result[0] = 0xbf;
Function encode
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function encode(command: ICommand): ICommandWithRaw {
const {
commandFlags = [Flags.requestsResponse, Flags.resetsInactivityTimeout],
deviceId,
commandId,
Function hid
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const hid = async (toy: SpheroMini) => {
let calibrating = false;
let offset = 0;
let stopped = false;
let heading: number;
Function add
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
add(byte: number) {
switch (byte) {
case APIConstants.startOfPacket:
if (msg.length !== 0) {
init();
Function loop
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
const loop = async () => {
// eslint-disable-next-line no-constant-condition
while (true) {
if (state) {
const { angle, module } = state.leftStick;
Function hid
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export const hid = async (toy: LightningMcQueen) => {
// let stopped = false;
let heading: number;
const loop = async () => {
- 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
Function calculateDomeAngle
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private calculateDomeAngle(angle: number) {
const result = new Uint8Array(2);
switch (angle) {
case -1:
result[0] = 0xbf;
- 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
Function sensorValuesToRawV2
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const sensorValuesToRawV2 = (
sensorMask: SensorMaskValues[],
apiVersion: APIVersion = APIVersion.V2
) =>
sensorMask.reduce((v2, m) => {
- 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
Avoid too many return
statements within this function. Open
return;
Avoid too many return
statements within this function. Open
return init();
Avoid too many return
statements within this function. Open
return error('Invalid escape char position');
Avoid too many return
statements within this function. Open
return error('Invalid no escape char end found');