privly/privly-applications

View on GitHub
shared/javascripts/viewAdapters/seamless.js

Summary

Maintainability
F
4 days
Test Coverage

File seamless.js has 471 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @fileOverview The seamless-posting adapter.
 *
 * This adapter is designed to be loaded in an seamless-posting iframe.
 * It needs seamless-posting content scripts to work correctly.
Severity: Minor
Found in shared/javascripts/viewAdapters/seamless.js - About 7 hrs to fix

    Function onConnectionCheckSucceeded has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      SeamlessAdapter.prototype.onConnectionCheckSucceeded = function () {
        var self = this;
        return self
          .emitAsync('connectionCheckSucceeded')
          .then(self.getTTLOptions.bind(self))
    Severity: Minor
    Found in shared/javascripts/viewAdapters/seamless.js - About 1 hr to fix

      Function createLink has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        SeamlessAdapter.prototype.createLink = function () {
          var self = this;
          return self
            .getRequestContent($('textarea').val())
            .then(function (json) {
      Severity: Minor
      Found in shared/javascripts/viewAdapters/seamless.js - About 1 hr to fix

        Function updateLink has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          SeamlessAdapter.prototype.updateLink = function () {
            var self = this;
        
            if (self.privlyUrl === null) {
              return Promise.resolve();
        Severity: Minor
        Found in shared/javascripts/viewAdapters/seamless.js - About 1 hr to fix

          Function SeamlessAdapter has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            var SeamlessAdapter = function (application, options) {
              /**
               * The Privly URL that is created to insert to the editable element.
               * 
               * @type {String}
          Severity: Minor
          Found in shared/javascripts/viewAdapters/seamless.js - About 1 hr to fix

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

              SeamlessAdapter.prototype.start = function () {
                var self = this;
                if (self.started) {
                  return;
                }
            Severity: Minor
            Found in shared/javascripts/viewAdapters/seamless.js - About 1 hr to fix

              Function loadLink has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                SeamlessAdapter.prototype.loadLink = function (link) {
                  var self = this;
                  var url = privlyParameters.getApplicationUrl(link);
                  var reqUrl = privlyParameters.getParameterHash(url).privlyDataURL;
              
              
              Severity: Minor
              Found in shared/javascripts/viewAdapters/seamless.js - About 1 hr to fix

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

                  SeamlessAdapter.prototype.getRequestContent = function (content) {
                    var promise;
                    if (typeof this.application.getRequestContent === 'function') {
                      promise = this.application.getRequestContent(content);
                    } else {
                Severity: Major
                Found in shared/javascripts/viewAdapters/seamless.js and 1 other location - About 7 hrs to fix
                shared/javascripts/viewAdapters/new.js on lines 184..203

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

                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

                  SeamlessAdapter.prototype.messageExtension = function (message, hasResponse) {
                    var messageToSend = JSON.parse(JSON.stringify(message));
                    // specify which context to be received
                    messageToSend.targetContextId = this.sourceContextId;
                    messageToSend.targetResourceId = this.sourceResourceId;
                Severity: Major
                Found in shared/javascripts/viewAdapters/seamless.js and 1 other location - About 3 hrs to fix
                shared/javascripts/viewAdapters/seamless_ttlselect.js on lines 59..66

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

                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

                  SeamlessAdapter.prototype.postprocessLink = function (link) {
                    var promise;
                    if (typeof this.application.postprocessLink === 'function') {
                      promise = this.application.postprocessLink(link);
                    } else {
                Severity: Major
                Found in shared/javascripts/viewAdapters/seamless.js and 1 other location - About 2 hrs to fix
                shared/javascripts/viewAdapters/new.js on lines 213..221

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

                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

                  SeamlessAdapter.prototype.getTTLOptions = function () {
                    var promise;
                    if (typeof this.application.getTTLOptions === 'function') {
                      promise = this.application.getTTLOptions();
                    } else {
                Severity: Major
                Found in shared/javascripts/viewAdapters/seamless.js and 1 other location - About 2 hrs to fix
                shared/javascripts/viewAdapters/seamless_ttlselect.js on lines 103..111

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

                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

                    if (window.location.search.indexOf('?') === 0) {
                      var query = privlyParameters.parameterStringToHash(window.location.search.substr(1));
                      this.sourceContextId = query.contextid;
                      this.sourceResourceId = query.resid;
                      this.selfAppId = query.appid;
                Severity: Major
                Found in shared/javascripts/viewAdapters/seamless.js and 1 other location - About 2 hrs to fix
                shared/javascripts/viewAdapters/seamless_ttlselect.js on lines 41..46

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

                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

                    privlyNetworkService.initPrivlyService(
                      privlyNetworkService.contentServerDomain(),
                      self.onConnectionCheckSucceeded.bind(self),
                      self.onConnectionCheckFailed.bind(self),
                      self.onConnectionCheckFailed.bind(self)
                Severity: Major
                Found in shared/javascripts/viewAdapters/seamless.js and 1 other location - About 1 hr to fix
                shared/javascripts/viewAdapters/new.js on lines 254..259

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

                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

                    Privly.message.addListener(function (message, sendResponse) {
                      if (message.targetAppId !== self.selfAppId) {
                        return;
                      }
                      return self.onMessageReceived(message, sendResponse);
                Severity: Minor
                Found in shared/javascripts/viewAdapters/seamless.js and 1 other location - About 55 mins to fix
                shared/javascripts/viewAdapters/seamless_ttlselect.js on lines 199..204

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

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

                  SeamlessAdapter.prototype.msgInsertLink = function (link) {
                    return this.messageExtension({
                      action: 'posting/contentScript/insertLink',
                      link: link
                    }, true);
                Severity: Major
                Found in shared/javascripts/viewAdapters/seamless.js and 3 other locations - About 40 mins to fix
                shared/javascripts/viewAdapters/seamless.js on lines 291..296
                shared/javascripts/viewAdapters/seamless.js on lines 322..327
                shared/javascripts/viewAdapters/seamless_ttlselect.js on lines 88..93

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

                  SeamlessAdapter.prototype.msgEmitEnterEvent = function (keys) {
                    return this.messageExtension({
                      action: 'posting/contentScript/emitEnterEvent',
                      keys: keys
                    }, true);
                Severity: Major
                Found in shared/javascripts/viewAdapters/seamless.js and 3 other locations - About 40 mins to fix
                shared/javascripts/viewAdapters/seamless.js on lines 291..296
                shared/javascripts/viewAdapters/seamless.js on lines 304..309
                shared/javascripts/viewAdapters/seamless_ttlselect.js on lines 88..93

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

                  SeamlessAdapter.prototype.msgSetTargetText = function (text) {
                    return this.messageExtension({
                      action: 'posting/contentScript/setTargetText',
                      text: text
                    }, true);
                Severity: Major
                Found in shared/javascripts/viewAdapters/seamless.js and 3 other locations - About 40 mins to fix
                shared/javascripts/viewAdapters/seamless.js on lines 304..309
                shared/javascripts/viewAdapters/seamless.js on lines 322..327
                shared/javascripts/viewAdapters/seamless_ttlselect.js on lines 88..93

                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

                  SeamlessAdapter.prototype.msgStopLoading = function () {
                    return this.messageExtension({
                      action: 'posting/contentScript/loading',
                      state: false
                    });
                Severity: Minor
                Found in shared/javascripts/viewAdapters/seamless.js and 1 other location - About 35 mins to fix
                shared/javascripts/viewAdapters/seamless.js on lines 240..245

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

                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

                  SeamlessAdapter.prototype.msgStartLoading = function () {
                    return this.messageExtension({
                      action: 'posting/contentScript/loading',
                      state: true
                    });
                Severity: Minor
                Found in shared/javascripts/viewAdapters/seamless.js and 1 other location - About 35 mins to fix
                shared/javascripts/viewAdapters/seamless.js on lines 252..257

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

                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