Showing 70 of 724 total issues
Function validateSubmission
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
module.exports.validateSubmission = (submission) => {
if (typeof submission.stage !== 'string') {
return {pass: false, message: 'stage data is missing'};
}
- 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 ioGenerator
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
ioGenerator: (random) => {
// Durstenfeld shuffle
const shuffleArray = (array) => {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(random() * (i + 1));
Function ioGenerator
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
ioGenerator: (random) => {
const numbers = [0, 0, 0];
const primes = [2];
for (let i = 3; i < 256; i++) {
let flag = null;
Function ioGenerator
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
ioGenerator: (random) => {
const getMedian = (input) => input.slice(0).sort((a, b) => a - b)[(input.length - 1) / 2];
const isMedianUnique = (input) => {
const median = getMedian(input);
Function ioGenerator
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
ioGenerator: (random) => {
const candidates = Array.from({length: 99}, (item, index) => index + 1); // 1..100
const swap = (index1, index2) => {
const temp = candidates[index1];
Function ioGenerator
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
ioGenerator: (random) => {
const calc = (number) => (
number.toString().split('').map((digit) => (
[1, 0, 0, 0, 1, 0, 1, 0, 2, 1][parseInt(digit)]
)).reduce((previous, current) => previous + current)
Function constructor
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
constructor(props, state) {
super(props, state);
// Currently, initial status should be always 'stop'
assert(props.status === 'stop');
Function ioGenerator
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
ioGenerator: (random) => {
// Durstenfeld shuffle
const shuffleArray = (array) => {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(random() * (i + 1));
Function updateSaveEntries
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
updateSaveEntries() {
const entries = this.getSaveEntries();
this.$savePanel.find('.saved-entries').empty().append(entries.map((entry) => (
$('<li/>', {
class: 'saved-item',
Function constructor
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
constructor(config) {
super();
this.rotate = config.rotate || 0;
this.name = config.name;
this.config = config;
Function render
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
return (
<g transform={this.getInitialTransform()}>
<rect
x={-this.getRectangleWidth() / 2}
Function ioGenerator
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
ioGenerator: (random) => {
const sumOfDigits = (n) => (
n.toString().split('').map((d) => parseInt(d)).reduce((a, b) => a + b)
);
Function ioGenerator
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
ioGenerator: (random) => {
const fibonacci = [1, 1];
for (let i = 2; i < 30; i++) {
fibonacci.push(fibonacci[fibonacci.length - 1] + fibonacci[fibonacci.length - 2]);
Function ioGenerator
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
ioGenerator: (random) => {
const fibonacci = [1, 1];
for (let i = 2; i < 20; i++) {
fibonacci.push(fibonacci[fibonacci.length - 1] + fibonacci[fibonacci.length - 2]);
Function message
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const message = (() => {
if (!arrayEquals(Object.keys(block), ['x', 'y', 'type', 'rotate'])) {
return `keys of block ${index} are invalid`;
}
Function ioGenerator
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
ioGenerator: (random) => {
const candidates = [0, 1, 2, 4, 6];
const inputs = [];
// Shuffle array and take heading 3
Function constructor
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
constructor(config) {
super();
this.height = config.height;
this.width = config.width;
Function onRegister
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async onRegister(event) {
const registrationStartTime = Date.now();
const name = this.$result.find('.name').val();
if (name.length === 0) {
Function ioGenerator
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
ioGenerator: (random) => {
const candidates = Array.from({length: 13}, (item, index) => index + 2); // 2..14
const inputs = [];
// Shuffle array and take heading 3
Function takeAndPlace
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
takeAndPlace(x, y, blockName) {
const oldBlock = this.boardComponent.getBlock(x, y);
assert(oldBlock, 'oldBlock is invalid');
if (!blockName || blockName === oldBlock.config.name) { // rotate the block
- 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"