alessandrocuzzocrea/chip-8-emulator-js

View on GitHub

Showing 50 of 76 total issues

Function decode has a Cognitive Complexity of 90 (exceeds 5 allowed). Consider refactoring.
Open

function decode(chip, opcode, keyboard, logger) {
  const a = (opcode >> 12) & 0xf;
  const b = (opcode >> 8) & 0xf;
  const c = (opcode >> 4) & 0xf;
  const d = opcode & 0xf;
Severity: Minor
Found in src/chip8.js - About 1 day 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

File chip8.js has 625 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const cloneDeep = require("lodash/cloneDeep");
const values = require("lodash/values");
const range = require("lodash/range");

const consts = require("./consts");
Severity: Major
Found in src/chip8.js - About 1 day to fix

    Function decode has 193 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function decode(chip, opcode, keyboard, logger) {
      const a = (opcode >> 12) & 0xf;
      const b = (opcode >> 8) & 0xf;
      const c = (opcode >> 4) & 0xf;
      const d = opcode & 0xf;
    Severity: Major
    Found in src/chip8.js - About 7 hrs to fix

      Function decode2 has 135 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function decode2(chip, pc) {
        const opcode = fetch(chip, pc);
        const a = (opcode >> 12) & 0xf;
        const b = (opcode >> 8) & 0xf;
        const c = (opcode >> 4) & 0xf;
      Severity: Major
      Found in src/chip8.js - About 5 hrs to fix

        Function decode2 has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

        function decode2(chip, pc) {
          const opcode = fetch(chip, pc);
          const a = (opcode >> 12) & 0xf;
          const b = (opcode >> 8) & 0xf;
          const c = (opcode >> 4) & 0xf;
        Severity: Minor
        Found in src/chip8.js - About 4 hrs 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 update has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function update(chip) {
          function formatDebugString(str, digits, val) {
            return `${str}: ${val
              .toString(16)
              .padStart(digits, "0")
        Severity: Major
        Found in src/ui.js - About 2 hrs to fix

          Function exports has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = env => {
            const GHPAGES = env && env.GHPAGES;
          
            const plugins = [
              new webpack.DefinePlugin({
          Severity: Minor
          Found in webpack.config.js - About 1 hr to fix

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

            function init() {
              canvas = document.querySelector("#emulator");
              romSelect = document.querySelector("select#rom-select");
              romSelect.onchange = e => loadRom(event.target.value);
            
            Severity: Minor
            Found in src/emulator.js - About 1 hr to fix

              Function drw has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function drw(chip8, x, y, byte) {
                let vf = 0;
                const xCoord = chip8.v[x];
                const yCoord = chip8.v[y];
                const i = chip8.i;
              Severity: Minor
              Found in src/chip8.js - About 35 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

              Avoid too many return statements within this function.
              Open

                      return module.exports.ldVxDT(chip, x);
              Severity: Major
              Found in src/chip8.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return module.exports.ldVxIndirectI(chip, x);
                Severity: Major
                Found in src/chip8.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return "SNE Vx, Vy";
                  Severity: Major
                  Found in src/chip8.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return "LD I, addr";
                    Severity: Major
                    Found in src/chip8.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return "LD Vx, Vy";
                      Severity: Major
                      Found in src/chip8.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return "ADD I, Vx";
                        Severity: Major
                        Found in src/chip8.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return module.exports.sne(chip, vx, byte);
                          Severity: Major
                          Found in src/chip8.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return "Fx29";
                            Severity: Major
                            Found in src/chip8.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return "Fx65";
                              Severity: Major
                              Found in src/chip8.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        return module.exports.ldDTVx(chip, x);
                                Severity: Major
                                Found in src/chip8.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                          return "LD Vx, byte";
                                  Severity: Major
                                  Found in src/chip8.js - About 30 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language