harella1/video.js

View on GitHub
src/js/tech/html5.js

Summary

Maintainability
F
5 days
Test Coverage

File html5.js has 552 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @file html5.js
 * HTML5 Media Controller - Wrapper for HTML5 Media API
 */

Severity: Major
Found in src/js/tech/html5.js - About 1 day to fix

    Html5 has 61 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Html5 extends Tech {
    
      constructor(options, ready){
        super(options, ready);
    
    
    Severity: Major
    Found in src/js/tech/html5.js - About 1 day to fix

      Function constructor has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

        constructor(options, ready){
          super(options, ready);
      
          const source = options.source;
          let crossoriginTracks = false;
      Severity: Minor
      Found in src/js/tech/html5.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 constructor has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        constructor(options, ready){
          super(options, ready);
      
          const source = options.source;
          let crossoriginTracks = false;
      Severity: Major
      Found in src/js/tech/html5.js - About 2 hrs to fix

        Function handleLateInit_ has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          handleLateInit_(el) {
            if (el.networkState === 0 || el.networkState === 3) {
              // The video element hasn't started loading the source yet
              // or didn't find a source
              return;
        Severity: Minor
        Found in src/js/tech/html5.js - About 1 hr to fix

          Function patchCanPlayType has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          Html5.patchCanPlayType = function() {
            // Android 4.0 and above can play HLS to some extent but it reports being unable to do so
            if (browser.ANDROID_VERSION >= 4.0) {
              if (!canPlayType) {
                canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType;
          Severity: Minor
          Found in src/js/tech/html5.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 createEl has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            createEl() {
              let el = this.options_.tag;
          
              // Check if this browser supports moving the element into the box.
              // On the iPhone video will break if you move the element,
          Severity: Minor
          Found in src/js/tech/html5.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 createEl has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            createEl() {
              let el = this.options_.tag;
          
              // Check if this browser supports moving the element into the box.
              // On the iPhone video will break if you move the element,
          Severity: Minor
          Found in src/js/tech/html5.js - About 1 hr to fix

            Function addRemoteTextTrack has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              addRemoteTextTrack(options={}) {
                if (!this['featuresNativeTextTracks']) {
                  return super.addRemoteTextTrack(options);
                }
            
            
            Severity: Minor
            Found in src/js/tech/html5.js - About 1 hr to fix

              Function addRemoteTextTrack has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                addRemoteTextTrack(options={}) {
                  if (!this['featuresNativeTextTracks']) {
                    return super.addRemoteTextTrack(options);
                  }
              
              
              Severity: Minor
              Found in src/js/tech/html5.js - About 45 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

              Function handleLateInit_ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                handleLateInit_(el) {
                  if (el.networkState === 0 || el.networkState === 3) {
                    // The video element hasn't started loading the source yet
                    // or didn't find a source
                    return;
              Severity: Minor
              Found in src/js/tech/html5.js - About 45 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 deeply nested control flow statements.
              Open

                          if (!crossoriginTracks &&
                              !this.el_.hasAttribute('crossorigin') &&
                              Url.isCrossOrigin(node.src)) {
                            crossoriginTracks = true;
                          }
              Severity: Major
              Found in src/js/tech/html5.js - About 45 mins to fix

                Function disposeMediaElement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                Html5.disposeMediaElement = function(el){
                  if (!el) { return; }
                
                  if (el.parentNode) {
                    el.parentNode.removeChild(el);
                Severity: Minor
                Found in src/js/tech/html5.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

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

                  if (browser.IS_OLD_ANDROID) {
                    if (!canPlayType) {
                      canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType;
                    }
                
                
                Severity: Major
                Found in src/js/tech/html5.js and 1 other location - About 3 hrs to fix
                src/js/tech/html5.js on lines 1159..1170

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

                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 (browser.ANDROID_VERSION >= 4.0) {
                    if (!canPlayType) {
                      canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType;
                    }
                
                
                Severity: Major
                Found in src/js/tech/html5.js and 1 other location - About 3 hrs to fix
                src/js/tech/html5.js on lines 1173..1184

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

                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 3 locations. Consider refactoring.
                Open

                  handleAudioTrackChange_(e) {
                    let audioTrackList = this.audioTracks();
                    this.audioTracks().trigger({
                      type: 'change',
                      target: audioTrackList,
                Severity: Major
                Found in src/js/tech/html5.js and 2 other locations - About 1 hr to fix
                src/js/tech/html5.js on lines 302..310
                src/js/tech/html5.js on lines 320..328

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

                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 3 locations. Consider refactoring.
                Open

                  handleTextTrackChange(e) {
                    let tt = this.textTracks();
                    this.textTracks().trigger({
                      type: 'change',
                      target: tt,
                Severity: Major
                Found in src/js/tech/html5.js and 2 other locations - About 1 hr to fix
                src/js/tech/html5.js on lines 320..328
                src/js/tech/html5.js on lines 338..346

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

                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 3 locations. Consider refactoring.
                Open

                  handleVideoTrackChange_(e) {
                    let vt = this.videoTracks();
                    this.videoTracks().trigger({
                      type: 'change',
                      target: vt,
                Severity: Major
                Found in src/js/tech/html5.js and 2 other locations - About 1 hr to fix
                src/js/tech/html5.js on lines 302..310
                src/js/tech/html5.js on lines 338..346

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

                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

                There are no issues that match your filters.

                Category
                Status