alessandrocuzzocrea/chip-8-emulator-js

View on GitHub

Showing 76 of 76 total issues

Similar blocks of code found in 6 locations. Consider refactoring.
Open

      if (c === 0x2 && d === 0x9) {
        const x = b;
        if (logger) logger.log(`Fx29, Vx=${x.toString(16)}`);
        return module.exports.ldFVx(chip, x);
      }
Severity: Major
Found in src/chip8.js and 5 other locations - About 2 hrs to fix
src/chip8.js on lines 461..465
src/chip8.js on lines 468..472
src/chip8.js on lines 474..478
src/chip8.js on lines 486..490
src/chip8.js on lines 492..496

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 78.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

      if (c === 0x5 && d === 0x5) {
        const x = b;
        if (logger) logger.log(`Fx55, Vx=${x.toString(16)}`);
        return module.exports.ldIndirectIVx(chip, x);
      }
Severity: Major
Found in src/chip8.js and 5 other locations - About 2 hrs to fix
src/chip8.js on lines 461..465
src/chip8.js on lines 468..472
src/chip8.js on lines 474..478
src/chip8.js on lines 480..484
src/chip8.js on lines 486..490

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 78.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

      if (c === 0x0 && d === 0x7) {
        const x = b;
        if (logger) logger.log(`Fx07 - LD Vx, DT, Vx=${x.toString(16)}`);
        return module.exports.ldVxDT(chip, x);
      }
Severity: Major
Found in src/chip8.js and 5 other locations - About 2 hrs to fix
src/chip8.js on lines 468..472
src/chip8.js on lines 474..478
src/chip8.js on lines 480..484
src/chip8.js on lines 486..490
src/chip8.js on lines 492..496

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 78.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

      if (c === 0x3 && d === 0x3) {
        const x = b;
        if (logger) logger.log(`Fx33, Vx=${x.toString(16)}`);
        return module.exports.ldB(chip, x);
      }
Severity: Major
Found in src/chip8.js and 5 other locations - About 2 hrs to fix
src/chip8.js on lines 461..465
src/chip8.js on lines 468..472
src/chip8.js on lines 474..478
src/chip8.js on lines 480..484
src/chip8.js on lines 492..496

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 78.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

      if (c === 0x1 && d === 0x5) {
        const x = b;
        if (logger) logger.log(`Fx15 - LD DT, Vx, Vx=${x.toString(16)}`);
        return module.exports.ldDTVx(chip, x);
      }
Severity: Major
Found in src/chip8.js and 5 other locations - About 2 hrs to fix
src/chip8.js on lines 461..465
src/chip8.js on lines 474..478
src/chip8.js on lines 480..484
src/chip8.js on lines 486..490
src/chip8.js on lines 492..496

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 78.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            if (c === 0xa && d === 0x1) {
              const x = b;
              if (logger) logger.log(`ExA1 - SKNP Vx, Vx=${x.toString(16)}`);
              return module.exports.sknp(chip, x, keyboard.getKeys());
            }
      Severity: Major
      Found in src/chip8.js and 1 other location - About 1 hr to fix
      src/chip8.js on lines 447..451

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 67.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            if (c === 0x9 && d === 0xe) {
              const x = b;
              if (logger) logger.log(`Ex9E - SKP Vx, Vx=${x.toString(16)}`);
              return module.exports.skp(chip, x, keyboard.getKeys());
            }
      Severity: Major
      Found in src/chip8.js and 1 other location - About 1 hr to fix
      src/chip8.js on lines 453..457

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 67.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      function shlX(chip8, x) {
        const vx = chip8.v[x];
        chip8.v[0xf] = vx >> 7;
        chip8.v[x] = vx << 1;
        return chip8;
      Severity: Major
      Found in src/chip8.js and 1 other location - About 1 hr to fix
      src/chip8.js on lines 161..166

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 66.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      function shrX(chip8, x) {
        const vx = chip8.v[x];
        chip8.v[0xf] = vx & 0b00000001;
        chip8.v[x] = vx >> 1;
        return chip8;
      Severity: Major
      Found in src/chip8.js and 1 other location - About 1 hr to fix
      src/chip8.js on lines 175..180

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 66.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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.se(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 module.exports.ldI(chip, nnn);
          Severity: Major
          Found in src/chip8.js - About 30 mins to fix

            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 "SKP Vx";
              Severity: Major
              Found in src/chip8.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return "SNE Vx, byte";
                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 "LD I, addr";
                    Severity: Major
                    Found in src/chip8.js - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language