betajs/betajs-media

View on GitHub
src/webrtc/webrtc_support.js

Summary

Maintainability
F
6 days
Test Coverage

Function userMedia2 has 242 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        userMedia2: function(options) {
            var opts = {};
            var promise;
            if (options.audio)
                opts.audio = options.audio;
Severity: Major
Found in src/webrtc/webrtc_support.js - About 1 day to fix

    File webrtc_support.js has 516 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    Scoped.define("module:WebRTC.Support", [
        "base:Promise",
        "base:Objs",
        "browser:Info",
        "browser:Dom",
    Severity: Major
    Found in src/webrtc/webrtc_support.js - About 1 day to fix

      Function enumerateMediaSources has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              enumerateMediaSources: function() {
                  var promise = Promise.create();
                  var promiseCallback = function(sources) {
                      var result = {
                          audio: {},
      Severity: Minor
      Found in src/webrtc/webrtc_support.js - About 1 hr to fix

        Function errorHandler has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                errorHandler: function(err) {
                    switch (err) {
                        case 'NotReadableError':
                        case 'TrackStartError':
                            return {
        Severity: Minor
        Found in src/webrtc/webrtc_support.js - About 1 hr to fix

          Function getGlobals has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  getGlobals: function() {
                      var getUserMedia = null;
                      var getUserMediaCtx = null;
          
                      if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
          Severity: Minor
          Found in src/webrtc/webrtc_support.js - About 1 hr to fix

            Function promiseCallback has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                        var promiseCallback = function(sources) {
                            var result = {
                                audio: {},
                                audioCount: 0,
                                video: {},
            Severity: Minor
            Found in src/webrtc/webrtc_support.js - About 1 hr to fix

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

                      bindStreamToVideo: function(stream, video, flip) {
                          if (!video)
                              video = document.createElement("video");
                          video.volume = 0;
                          video.muted = true;
              Severity: Minor
              Found in src/webrtc/webrtc_support.js - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                                    if (options.video.width)
                                        options.video.height = Math.round(options.video.width / options.video.aspectRatio);
                                    else if (options.video.height)
                                        options.video.width = Math.round(options.video.height * options.video.aspectRatio);
                Severity: Major
                Found in src/webrtc/webrtc_support.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if (e.name !== "ConstraintNotSatisfiedError" && e.name !== "OverconstrainedError")
                                              return e;
                  Severity: Major
                  Found in src/webrtc/webrtc_support.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if (!navigator.mediaDevices || !navigator.mediaDevices.getSupportedConstraints || !navigator.mediaDevices.getSupportedConstraints().mediaSource)
                                            return Promise.error("This browser does not support screen recording.");
                    Severity: Major
                    Found in src/webrtc/webrtc_support.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                      if (as) {
                                          if (typeof opts.video.mandatory !== 'undefined') {
                                              opts.video.mandatory.minAspectRatio = as;
                                              opts.video.mandatory.maxAspectRatio = as;
                                          } else {
                      Severity: Major
                      Found in src/webrtc/webrtc_support.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                        if (Info.isAndroid()) {
                                            opts.video = {};
                                        } else {
                                            opts.video = {
                                                mandatory: {}
                        Severity: Major
                        Found in src/webrtc/webrtc_support.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                          if (typeof opts.video.mandatory !== 'undefined') {
                                              if (options.video.width) {
                                                  opts.video.mandatory.minWidth = options.video.width;
                                                  opts.video.mandatory.maxWidth = options.video.width;
                                              }
                          Severity: Major
                          Found in src/webrtc/webrtc_support.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                            if (options.screen) {
                                                var extensionId = this.chromeExtensionExtract(options.screen).extensionId;
                                                if (!extensionId)
                                                    return Promise.error("This browser does not support screen recording.");
                                                var pingTest = Time.now();
                            Severity: Major
                            Found in src/webrtc/webrtc_support.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                          if (lkey.indexOf(c) >= 0) {
                                                              var flt = lkey.indexOf("aspect") > 0;
                                                              var d = lkey.indexOf("min") === 0 ? -1 : 1;
                                                              var u = Math.max(0, mandatory[key] * (1.0 + d / 10));
                                                              mandatory[key] = flt ? u : Math.round(u);
                              Severity: Major
                              Found in src/webrtc/webrtc_support.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                if (navigator.getDisplayMedia) {
                                                    promise = Promise.create();
                                                    var pr = navigator.getDisplayMedia({
                                                        video: true
                                                    });
                                Severity: Major
                                Found in src/webrtc/webrtc_support.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                  if (Info.isSafari()) {
                                                      if (options.video.sourceId) {
                                                          opts.video.sourceId = options.video.sourceId;
                                                          opts.video.deviceId = {
                                                              exact: options.video.sourceId
                                  Severity: Major
                                  Found in src/webrtc/webrtc_support.js - About 45 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                    return this.userMedia(opts);
                                    Severity: Major
                                    Found in src/webrtc/webrtc_support.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                          return this.chromeExtensionMessage(extensionId, {
                                                              type: "ping",
                                                              data: pingTest
                                                          }).mapSuccess(function(pingResponse) {
                                                              promise = Promise.create();
                                      Severity: Major
                                      Found in src/webrtc/webrtc_support.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                            return Promise.error("This browser does not support screen recording.");
                                        Severity: Major
                                        Found in src/webrtc/webrtc_support.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                              return promise;
                                          Severity: Major
                                          Found in src/webrtc/webrtc_support.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                            return probe.call(this, 100);
                                            Severity: Major
                                            Found in src/webrtc/webrtc_support.js - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                                      return Promise.error("This browser does not support screen recording.");
                                              Severity: Major
                                              Found in src/webrtc/webrtc_support.js - About 30 mins to fix

                                                TODO found
                                                Open

                                                                        // TODO: test it just in case
                                                Severity: Minor
                                                Found in src/webrtc/webrtc_support.js by fixme

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

                                                                    if (source.kind.indexOf("audio") === 0) {
                                                                        result.audioCount++;
                                                                        if (typeof source.getCapabilities !== 'undefined')
                                                                            _sourceCapabilities = source.getCapabilities();
                                                                        result.audio[source.id || source.deviceId] = {
                                                Severity: Major
                                                Found in src/webrtc/webrtc_support.js and 1 other location - About 4 hrs to fix
                                                src/webrtc/webrtc_support.js on lines 86..95

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

                                                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 (source.kind.indexOf("video") === 0) {
                                                                        result.videoCount++;
                                                                        if (typeof source.getCapabilities !== 'undefined')
                                                                            _sourceCapabilities = source.getCapabilities();
                                                                        result.video[source.id || source.deviceId] = {
                                                Severity: Major
                                                Found in src/webrtc/webrtc_support.js and 1 other location - About 4 hrs to fix
                                                src/webrtc/webrtc_support.js on lines 96..105

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

                                                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 (options.video.width) {
                                                                        opts.video.mandatory.minWidth = options.video.width;
                                                                        opts.video.mandatory.maxWidth = options.video.width;
                                                                    }
                                                Severity: Major
                                                Found in src/webrtc/webrtc_support.js and 1 other location - About 1 hr to fix
                                                src/webrtc/webrtc_support.js on lines 341..344

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

                                                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 (options.video.frameRate) {
                                                                        opts.video.mandatory.minFrameRate = options.video.frameRate;
                                                                        opts.video.mandatory.maxFrameRate = options.video.frameRate;
                                                                    }
                                                Severity: Major
                                                Found in src/webrtc/webrtc_support.js and 1 other location - About 1 hr to fix
                                                src/webrtc/webrtc_support.js on lines 331..334

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

                                                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 (parseInt(options.video.height, 10) > 0) {
                                                                    videoOptions.height = parseInt(options.video.height, 10);
                                                                }
                                                Severity: Minor
                                                Found in src/webrtc/webrtc_support.js and 1 other location - About 40 mins to fix
                                                src/webrtc/webrtc_support.js on lines 229..231

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

                                                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 (parseInt(options.video.width, 10) > 0) {
                                                                    videoOptions.width = parseInt(options.video.width, 10);
                                                                }
                                                Severity: Minor
                                                Found in src/webrtc/webrtc_support.js and 1 other location - About 40 mins to fix
                                                src/webrtc/webrtc_support.js on lines 232..234

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

                                                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