Showing 25 of 101 total issues
Function set
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
set (...colorDefinition) {
if (colorDefinition.length > 0 && colorDefinition.length < 3) {
const param = colorDefinition[0];
if (param instanceof Color) {
this.red = param.red;
- 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 listenForEvents
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
Scene.prototype[listenForEventsKey] = function listenForEvents (container) {
if (this.isReady) {
throw new EvalError("Can't rebind event a second time.");
}
Container
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
export default class Container extends EventEmitter {
/**
* Container constructor
* @param {PositionDefinition} [positionDefinition] - Position in its container
* @param {ContainerOptions} [options] - Specific options
Function listenForEvents
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
Scene.prototype[listenForEventsKey] = function listenForEvents (container) {
if (this.isReady) {
throw new EvalError("Can't rebind event a second time.");
}
- 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 makePath
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
makePath (ctx) {
const { options } = this;
if (this.text.length && (options.fill || (options.stroke && options.strokeWidth > 0))) {
ctx.save();
- 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 draggable
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
Component.prototype.draggable = function draggable (options) {
if (this.isDraggable) {
throw new Error("Component can't be both rotatable and draggable.");
}
Position
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
export default class Position {
/**
* Position constructor
* @param {Number} x - Vertical component
* @param {Number} y - Horizontal component
File container.test.js
has 258 lines of code (exceeds 250 allowed). Consider refactoring. Open
import test from "ava";
import Container from ".";
test.beforeEach((t) => {
t.context = new Container([10, 20]);
Function constructor
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor (positionDefinition, optionsList, options) {
if (!optionsList.length) {
throw new RangeError("Options list should have at least one item.");
}
super(positionDefinition, options);
File container.js
has 251 lines of code (exceeds 250 allowed). Consider refactoring. Open
import EventEmitter from "@pencil.js/event-emitter";
import BaseEvent from "@pencil.js/base-event";
import Position from "@pencil.js/position";
import { radianCircle } from "@pencil.js/math";
Function set
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
set (...colorDefinition) {
if (colorDefinition.length > 0 && colorDefinition.length < 3) {
const param = colorDefinition[0];
if (param instanceof Color) {
this.red = param.red;
Function cursors
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
static get cursors () {
const cursors = {
default: "default",
none: "none",
contextMenu: "context-menu",
Function render
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
render (ctx) {
if (!this.options.shown) {
return this;
}
Function resizable
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Rectangle.prototype.resizable = function resizable (options) {
if (this.options.rotation % 1 !== 0) {
throw new EvalError("Resizable don't support rotation.");
}
Function makePath
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
makePath (ctx) {
const { options } = this;
if (this.text.length && (options.fill || (options.stroke && options.strokeWidth > 0))) {
ctx.save();
Function rotatable
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Component.prototype.rotatable = function rotatable () {
if (this.isDraggable) {
throw new Error("Component can't be both draggable and rotatable.");
}
Function render
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
render (ctx) {
if (!this.options.shown) {
return this;
}
- 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 makePath
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
makePath (ctx) {
const { spriteSourceSize } = this.frames[Math.floor(this.frame)];
this.width = spriteSourceSize.w;
this.height = spriteSourceSize.h;
- 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 getAlignOffset
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
getAlignOffset () {
const { align } = this.options;
let offset = 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 getTarget
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
getTarget (position, ctx) {
if (!this.options.shown) {
return null;
}
- 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"