gkozlenko/node-video-lib

View on GitHub

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

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

                    if (fragmentList.video.codec) {
                        buffer.writeUInt16BE(fragmentList.video.codec.length, pos); pos += 2;
                        buffer.write(fragmentList.video.codec, pos); pos += fragmentList.video.codec.length;
                    } else {
                        buffer.writeUInt16BE(0, pos); pos += 2;
        Severity: Major
        Found in lib/index/fragment-list-indexer.js and 1 other location - About 3 hrs to fix
        lib/index/fragment-list-indexer.js on lines 64..69

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

        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 (fragmentList.audio.codec) {
                        buffer.writeUInt16BE(fragmentList.audio.codec.length, pos); pos += 2;
                        buffer.write(fragmentList.audio.codec, pos); pos += fragmentList.audio.codec.length;
                    } else {
                        buffer.writeUInt16BE(0, pos); pos += 2;
        Severity: Major
        Found in lib/index/fragment-list-indexer.js and 1 other location - About 3 hrs to fix
        lib/index/fragment-list-indexer.js on lines 47..52

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

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

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

              _readLongString() {
                  let size = this.buffer.readUInt32BE(this.pos);
                  this.pos += 4;
                  let value = this.buffer.toString('utf8', this.pos, this.pos + size);
                  this.pos += size;
          Severity: Major
          Found in lib/flv/amf-parser.js and 1 other location - About 2 hrs to fix
          lib/flv/amf-parser.js on lines 95..101

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

          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

              _readString() {
                  let size = this.buffer.readUInt16BE(this.pos);
                  this.pos += 2;
                  let value = this.buffer.toString('utf8', this.pos, this.pos + size);
                  this.pos += size;
          Severity: Major
          Found in lib/flv/amf-parser.js and 1 other location - About 2 hrs to fix
          lib/flv/amf-parser.js on lines 143..149

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

          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

              _readNalUnit() {
                  let length = this.extraData.readUInt16BE(this._pos);
                  this._pos += 2;
                  let unit = this.extraData.subarray(this._pos, this._pos + length);
                  this._pos += length;
          Severity: Major
          Found in lib/codecs/codec-h265.js and 1 other location - About 2 hrs to fix
          lib/codecs/codec-h264.js on lines 49..55

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

          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

              _readNalUnit() {
                  let length = this.extraData.readUInt16BE(this._pos);
                  this._pos += 2;
                  let unit = this.extraData.subarray(this._pos, this._pos + length);
                  this._pos += length;
          Severity: Major
          Found in lib/codecs/codec-h264.js and 1 other location - About 2 hrs to fix
          lib/codecs/codec-h265.js on lines 72..78

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

          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 _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

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

                      constructor() {
                          this.timestamp = 0;
                          this.duration = 0;
                          this.timescale = 0;
                          this.videoExtraData = null;
                  Severity: Major
                  Found in lib/fragment.js and 1 other location - About 2 hrs to fix
                  lib/fragment-list.js on lines 7..14

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

                  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

                      constructor() {
                          this.fragmentDuration = 0;
                          this.duration = 0;
                          this.timescale = 0;
                          this.video = null;
                  Severity: Major
                  Found in lib/fragment-list.js and 1 other location - About 2 hrs to fix
                  lib/fragment.js on lines 5..12

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

                  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