gkozlenko/node-video-lib

View on GitHub

Showing 50 of 79 total issues

Function _createTrack has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

    _createTrack(trakAtom) {
        let mdiaAtom = trakAtom.getAtom(Utils.ATOM_MDIA);
        if (mdiaAtom === null) {
            return;
        }
Severity: Minor
Found in lib/mp4/parser-impl.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 build has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
Open

    build() {
        // Tracks and Samples
        let tracks = [this.movie.videoTrack(), this.movie.audioTrack()]
            .filter(track => track !== null && track.samples.length > 0);
        let samples = tracks.reduce((array, track) => array.concat(track.samples), [])
Severity: Minor
Found in lib/mp4/builder-impl.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 build has 176 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    build() {
        // Tracks and Samples
        let tracks = [this.movie.videoTrack(), this.movie.audioTrack()]
            .filter(track => track !== null && track.samples.length > 0);
        let samples = tracks.reduce((array, track) => array.concat(track.samples), [])
Severity: Major
Found in lib/mp4/builder-impl.js - About 7 hrs to fix

    Function _packPayload has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        _packPayload(payload, sample, pid, dtsTime) {
            // Number of packets
            let numPackets = Math.ceil(payload.length / (PACKET_SIZE - 4));
            if (sample instanceof VideoSample && numPackets * (PACKET_SIZE - 4) - 8 < payload.length) {
                // Take into account adaptation field
    Severity: Minor
    Found in lib/hls/packetizer-impl.js - About 5 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 _createTrack has 133 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        _createTrack(trakAtom) {
            let mdiaAtom = trakAtom.getAtom(Utils.ATOM_MDIA);
            if (mdiaAtom === null) {
                return;
            }
    Severity: Major
    Found in lib/mp4/parser-impl.js - About 5 hrs to fix

      Function index has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          static index(fragmentList, fd) {
              // Calc buffer size and offsets
              let bufferSize = Utils.HEADER_SIZE;
              if (fragmentList.video) {
                  bufferSize += fragmentList.video.extraData.length + Utils.HEADER_VIDEO_SIZE;
      Severity: Minor
      Found in lib/index/fragment-list-indexer.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

      File packetizer-impl.js has 320 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      'use strict';
      
      const crc32 = require('./crc32');
      const SampleCounter = require('./sample-counter');
      
      
      Severity: Minor
      Found in lib/hls/packetizer-impl.js - About 3 hrs to fix

        Function index has 80 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            static index(fragmentList, fd) {
                // Calc buffer size and offsets
                let bufferSize = Utils.HEADER_SIZE;
                if (fragmentList.video) {
                    bufferSize += fragmentList.video.extraData.length + Utils.HEADER_VIDEO_SIZE;
        Severity: Major
        Found in lib/index/fragment-list-indexer.js - About 3 hrs to fix

          Function _buildHeader has 64 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _buildHeader() {
                  let buffer = Buffer.allocUnsafe(2 * PACKET_SIZE);
                  let pos = 0;
          
                  // Write PAT packet
          Severity: Major
          Found in lib/hls/packetizer-impl.js - About 2 hrs to fix

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

                constructor(fd) {
                    super();
            
                    this.fd = fd;
            
            
            Severity: Major
            Found in lib/index/indexed-fragment-list.js - About 2 hrs to fix

              Function _packPayload has 54 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  _packPayload(payload, sample, pid, dtsTime) {
                      // Number of packets
                      let numPackets = Math.ceil(payload.length / (PACKET_SIZE - 4));
                      if (sample instanceof VideoSample && numPackets * (PACKET_SIZE - 4) - 8 < payload.length) {
                          // Take into account adaptation field
              Severity: Major
              Found in lib/hls/packetizer-impl.js - About 2 hrs to fix

                Function build has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    static build(movie, fragmentDuration) {
                        let fragmentList = new FragmentList();
                        fragmentList.fragmentDuration = fragmentDuration;
                        fragmentList.duration = movie.duration * FRAGMENT_TIMESCALE / movie.timescale;
                        fragmentList.timescale = FRAGMENT_TIMESCALE;
                Severity: Major
                Found in lib/fragment-list-builder.js - About 2 hrs to fix

                  Function packFragment has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      packFragment() {
                          let buffers = [];
                          let buffersLength = 0;
                          let packetTimescale = 90 * this.fragment.timescale;
                  
                  
                  Severity: Minor
                  Found in lib/hls/packetizer-impl.js - About 1 hr to fix

                    Function packFragment has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        packFragment() {
                            let buffers = [];
                            let buffersLength = 0;
                            let packetTimescale = 90 * this.fragment.timescale;
                    
                    
                    Severity: Minor
                    Found in lib/hls/packetizer-impl.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 _readByType has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        _readByType(type) {
                            switch (type) {
                                case TYPE_NUMBER: {
                                    return this._readDouble();
                                }
                    Severity: Minor
                    Found in lib/flv/amf-parser.js - About 1 hr to fix

                      Function readSamples has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          static readSamples(fragment, source) {
                              // Collect entries
                              let entries = fragment.samples.map((sample, i) => {
                                  return {
                                      index: i,
                      Severity: Minor
                      Found in lib/fragment-reader.js - About 1 hr to fix

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

                            get(index) {
                                if (index >= this._fragmentsCount) {
                                    return;
                                }
                                let bufFragment = Buffer.allocUnsafe(Utils.FRAGMENT_SIZE);
                        Severity: Minor
                        Found in lib/index/indexed-fragment-list.js - About 1 hr to fix

                          Function parse has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              parse(buffer) {
                                  let offset = 5;
                          
                                  // ES_Length
                                  let esSize = readSize(buffer, offset);
                          Severity: Minor
                          Found in lib/mp4/atoms/atom-esds.js - About 1 hr to fix

                            Function parse has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                parse(buffer) {
                                    let offset = 8;
                                    let version = buffer.readUInt16BE(offset);
                                    offset += 8;
                                    this.channels = buffer.readUInt16BE(offset);
                            Severity: Minor
                            Found in lib/mp4/atoms/atom-mp4a.js - About 1 hr to fix

                              Function _findMoovAtom has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  _findMoovAtom() {
                                      this.moovAtom = null;
                              
                                      let pos = 0;
                                      let size = this.reader.size();
                              Severity: Minor
                              Found in lib/mp4/parser-impl.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

                              Severity
                              Category
                              Status
                              Source
                              Language