nfroidure/midievents

View on GitHub

Showing 33 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

            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

              Avoid deeply nested control flow statements.
              Open

                          if (strictMode && 59 < events[i].seconds) {
                            throw new Error(
                              'Event #' +
                                i +
                                ': SMTPE offset seconds value must' +
              Severity: Major
              Found in src/midievents.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            for (k = 0, l = events[i].length; k < l; k++) {
                              destination[index++] = events[i].data[k];
                            }
                Severity: Major
                Found in src/midievents.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              if (
                                'number' !== typeof events[i].scale ||
                                0 > events[i].scale ||
                                1 < events[i].scale
                              ) {
                  Severity: Major
                  Found in src/midievents.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                if (strictMode && 99 < events[i].subframes) {
                                  throw new Error(
                                    'Event #' +
                                      i +
                                      ': SMTPE offset subframes amount' +
                    Severity: Major
                    Found in src/midievents.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                  for (k = 0, l = events[i].length; k < l; k++) {
                                    destination[index++] = events[i].data[k];
                                  }
                      Severity: Major
                      Found in src/midievents.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                    if (strictMode && 23 < events[i].hour) {
                                      throw new Error(
                                        'Event #' +
                                          i +
                                          ': SMTPE offset hour value must be' +
                        Severity: Major
                        Found in src/midievents.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                      if (strictMode && 59 < events[i].minutes) {
                                        throw new Error(
                                          'Event #' +
                                            i +
                                            ': SMTPE offset minutes value must' +
                          Severity: Major
                          Found in src/midievents.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                        if (
                                          'number' != typeof events[i].key ||
                                          -7 > events[i].key ||
                                          7 < events[i].scale
                                        ) {
                            Severity: Major
                            Found in src/midievents.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          if (strictMode && 30 < events[i].frames) {
                                            throw new Error(
                                              'Event #' +
                                                i +
                                                ': SMTPE offset frames amount must' +
                              Severity: Major
                              Found in src/midievents.js - About 45 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                            return event;
                                Severity: Major
                                Found in src/midievents.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                                return event;
                                  Severity: Major
                                  Found in src/midievents.js - About 30 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language