nfroidure/midievents

View on GitHub

Showing 167 of 167 total issues

Function midiEventsCreateParser has a Cognitive Complexity of 132 (exceeds 5 allowed). Consider refactoring.
Open

MIDIEvents.createParser = function midiEventsCreateParser(
  stream,
  startAt,
  strictMode
) {
Severity: Minor
Found in src/midievents.js - About 2 days 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 midiEventsWriteToTrack has a Cognitive Complexity of 88 (exceeds 5 allowed). Consider refactoring.
Open

MIDIEvents.writeToTrack = function midiEventsWriteToTrack(
  events,
  destination,
  strictMode
) {
Severity: Minor
Found in src/midievents.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

Function midiEventsCreateParser has 282 lines of code (exceeds 25 allowed). Consider refactoring.
Open

MIDIEvents.createParser = function midiEventsCreateParser(
  stream,
  startAt,
  strictMode
) {
Severity: Major
Found in src/midievents.js - About 1 day to fix

    File midievents.js has 542 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    // MIDIEvents : Read and edit events from various sources (ArrayBuffer, Stream)
    function MIDIEvents() {
      throw new Error('MIDIEvents function not intended to be run.');
    Severity: Major
    Found in src/midievents.js - About 1 day to fix

      Function next has 220 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          next: function() {
            // Check available datas
            if (stream.end()) {
              return null;
            }
      Severity: Major
      Found in src/midievents.js - About 1 day to fix

        Function midiEventsWriteToTrack has 169 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        MIDIEvents.writeToTrack = function midiEventsWriteToTrack(
          events,
          destination,
          strictMode
        ) {
        Severity: Major
        Found in src/midievents.js - About 6 hrs to fix

          File midievents.mocha.js has 395 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          'use strict';
          
          var assert = require('assert');
          var MIDIEvents = require('../src/midievents');
          
          
          Severity: Minor
          Found in src/midievents.mocha.js - About 5 hrs to fix

            Function getRequiredBufferLength has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
            Open

            MIDIEvents.getRequiredBufferLength = function(events) {
              var bufferLength = 0;
              var i = 0;
              var j;
            
            
            Severity: Minor
            Found in src/midievents.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

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

                  bufferLength +=
                    events[i].length >>> 21
                      ? 4
                      : events[i].length >>> 14
                        ? 3
            Severity: Major
            Found in src/midievents.js and 1 other location - About 1 hr to fix
            src/midievents.js on lines 563..570

            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 65.

            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

                bufferLength +=
                  events[i].delta >>> 21
                    ? 4
                    : events[i].delta >>> 14
                      ? 3
            Severity: Major
            Found in src/midievents.js and 1 other location - About 1 hr to fix
            src/midievents.js on lines 590..597

            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 65.

            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

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

                      case MIDIEvents.EVENT_META_CUE_POINT:
                        for (k = 0, l = events[i].length; k < l; k++) {
                          destination[index++] = events[i].data[k];
                        }
                        break;
            Severity: Major
            Found in src/midievents.js and 1 other location - About 1 hr to fix
            src/midievents.js on lines 538..542

            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 63.

            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 getRequiredBufferLength has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            MIDIEvents.getRequiredBufferLength = function(events) {
              var bufferLength = 0;
              var i = 0;
              var j;
            
            
            Severity: Minor
            Found in src/midievents.js - About 1 hr to fix

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

                        default:
                          for (k = 0, l = events[i].length; k < l; k++) {
                            destination[index++] = events[i].data[k];
                          }
                          break;
              Severity: Major
              Found in src/midievents.js and 1 other location - About 1 hr to fix
              src/midievents.js on lines 448..452

              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 63.

              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 (events[i].length >>> 21) {
                      destination[index++] = ((events[i].length >>> 21) & 0x7f) | 0x80;
                    }
              Severity: Major
              Found in src/midievents.js and 5 other locations - About 50 mins to fix
              src/midievents.js on lines 388..390
              src/midievents.js on lines 391..393
              src/midievents.js on lines 394..396
              src/midievents.js on lines 429..431
              src/midievents.js on lines 432..434

              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 52.

              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 (events[i].length >>> 28) {
                      throw Error(
                        'Event #' +
                          i +
                          ': Maximum length reached (' +
              Severity: Minor
              Found in src/midievents.js and 1 other location - About 50 mins to fix
              src/midievents.js on lines 379..387

              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 52.

              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 (events[i].delta >>> 7) {
                    destination[index++] = ((events[i].delta >>> 7) & 0x7f) | 0x80;
                  }
              Severity: Major
              Found in src/midievents.js and 5 other locations - About 50 mins to fix
              src/midievents.js on lines 388..390
              src/midievents.js on lines 391..393
              src/midievents.js on lines 426..428
              src/midievents.js on lines 429..431
              src/midievents.js on lines 432..434

              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 52.

              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 (events[i].delta >>> 28) {
                    throw Error(
                      'Event #' +
                        i +
                        ': Maximum delta time value reached (' +
              Severity: Minor
              Found in src/midievents.js and 1 other location - About 50 mins to fix
              src/midievents.js on lines 417..425

              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 52.

              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 (events[i].length >>> 14) {
                      destination[index++] = ((events[i].length >>> 14) & 0x7f) | 0x80;
                    }
              Severity: Major
              Found in src/midievents.js and 5 other locations - About 50 mins to fix
              src/midievents.js on lines 388..390
              src/midievents.js on lines 391..393
              src/midievents.js on lines 394..396
              src/midievents.js on lines 426..428
              src/midievents.js on lines 432..434

              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 52.

              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 (events[i].delta >>> 21) {
                    destination[index++] = ((events[i].delta >>> 21) & 0x7f) | 0x80;
                  }
              Severity: Major
              Found in src/midievents.js and 5 other locations - About 50 mins to fix
              src/midievents.js on lines 391..393
              src/midievents.js on lines 394..396
              src/midievents.js on lines 426..428
              src/midievents.js on lines 429..431
              src/midievents.js on lines 432..434

              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 52.

              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 (events[i].delta >>> 14) {
                    destination[index++] = ((events[i].delta >>> 14) & 0x7f) | 0x80;
                  }
              Severity: Major
              Found in src/midievents.js and 5 other locations - About 50 mins to fix
              src/midievents.js on lines 388..390
              src/midievents.js on lines 394..396
              src/midievents.js on lines 426..428
              src/midievents.js on lines 429..431
              src/midievents.js on lines 432..434

              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 52.

              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

              Severity
              Category
              Status
              Source
              Language