tsg-ut/mnemo

View on GitHub

Showing 70 of 724 total issues

Function validateSubmission has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

module.exports.validateSubmission = (submission) => {
    if (typeof submission.stage !== 'string') {
        return {pass: false, message: 'stage data is missing'};
    }

Severity: Minor
Found in lib/validator.js - About 1 hr 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

Function ioGenerator has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    ioGenerator: (random) => {
        // Durstenfeld shuffle
        const shuffleArray = (array) => {
            for (let i = array.length - 1; i > 0; i--) {
                const j = Math.floor(random() * (i + 1));
Severity: Minor
Found in stages/gcd.js - About 1 hr to fix

    Function ioGenerator has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        ioGenerator: (random) => {
            const numbers = [0, 0, 0];
            const primes = [2];
            for (let i = 3; i < 256; i++) {
                let flag = null;
    Severity: Minor
    Found in stages/factorization.js - About 1 hr to fix

      Function ioGenerator has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      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);
      Severity: Minor
      Found in stages/the-fifth-max.js - About 1 hr to fix

        Function ioGenerator has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            ioGenerator: (random) => {
                const candidates = Array.from({length: 99}, (item, index) => index + 1); // 1..100
        
                const swap = (index1, index2) => {
                    const temp = candidates[index1];
        Severity: Minor
        Found in stages/spaceship.js - About 1 hr to fix

          Function ioGenerator has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          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)
          Severity: Minor
          Found in stages/8809.js - About 1 hr to fix

            Function constructor has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                constructor(props, state) {
                    super(props, state);
            
                    // Currently, initial status should be always 'stop'
                    assert(props.status === 'stop');
            Severity: Minor
            Found in lib/board-component.jsx - About 1 hr to fix

              Function ioGenerator has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  ioGenerator: (random) => {
                      // Durstenfeld shuffle
                      const shuffleArray = (array) => {
                          for (let i = array.length - 1; i > 0; i--) {
                              const j = Math.floor(random() * (i + 1));
              Severity: Minor
              Found in stages/lcm.js - About 1 hr to fix

                Function updateSaveEntries has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    updateSaveEntries() {
                        const entries = this.getSaveEntries();
                        this.$savePanel.find('.saved-entries').empty().append(entries.map((entry) => (
                            $('<li/>', {
                                class: 'saved-item',
                Severity: Minor
                Found in lib/stage.js - About 1 hr to fix

                  Function constructor has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      constructor(config) {
                          super();
                          this.rotate = config.rotate || 0;
                          this.name = config.name;
                          this.config = config;
                  Severity: Minor
                  Found in lib/block.js - About 1 hr to fix

                    Function render has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        render() {
                            return (
                                <g transform={this.getInitialTransform()}>
                                    <rect
                                        x={-this.getRectangleWidth() / 2}
                    Severity: Minor
                    Found in lib/data-component.jsx - About 1 hr to fix

                      Function ioGenerator has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          ioGenerator: (random) => {
                              const sumOfDigits = (n) => (
                                  n.toString().split('').map((d) => parseInt(d)).reduce((a, b) => a + b)
                              );
                      
                      
                      Severity: Minor
                      Found in stages/parity.js - About 1 hr to fix

                        Function ioGenerator has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            ioGenerator: (random) => {
                                const fibonacci = [1, 1];
                        
                                for (let i = 2; i < 30; i++) {
                                    fibonacci.push(fibonacci[fibonacci.length - 1] + fibonacci[fibonacci.length - 2]);
                        Severity: Minor
                        Found in stages/fibonacci-hard.js - About 1 hr to fix

                          Function ioGenerator has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              ioGenerator: (random) => {
                                  const fibonacci = [1, 1];
                          
                                  for (let i = 2; i < 20; i++) {
                                      fibonacci.push(fibonacci[fibonacci.length - 1] + fibonacci[fibonacci.length - 2]);
                          Severity: Minor
                          Found in stages/fibonacci.js - About 1 hr to fix

                            Function message has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    const message = (() => {
                                        if (!arrayEquals(Object.keys(block), ['x', 'y', 'type', 'rotate'])) {
                                            return `keys of block ${index} are invalid`;
                                        }
                            
                            
                            Severity: Minor
                            Found in lib/validator.js - About 1 hr to fix

                              Function ioGenerator has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  ioGenerator: (random) => {
                                      const candidates = [0, 1, 2, 4, 6];
                                      const inputs = [];
                              
                                      // Shuffle array and take heading 3
                              Severity: Minor
                              Found in stages/conditional03.js - About 1 hr to fix

                                Function constructor has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    constructor(config) {
                                        super();
                                
                                        this.height = config.height;
                                        this.width = config.width;
                                Severity: Minor
                                Found in lib/board.js - About 1 hr to fix

                                  Function onRegister has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      async onRegister(event) {
                                          const registrationStartTime = Date.now();
                                  
                                          const name = this.$result.find('.name').val();
                                          if (name.length === 0) {
                                  Severity: Minor
                                  Found in lib/stage.js - About 1 hr to fix

                                    Function ioGenerator has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        ioGenerator: (random) => {
                                            const candidates = Array.from({length: 13}, (item, index) => index + 2); // 2..14
                                            const inputs = [];
                                    
                                            // Shuffle array and take heading 3
                                    Severity: Minor
                                    Found in stages/factorial.js - About 1 hr to fix

                                      Function takeAndPlace has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                      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
                                      Severity: Minor
                                      Found in lib/stage.js - About 55 mins 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

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language