privly/privly-applications

View on GitHub

Showing 109 of 109 total issues

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 initializeNavigation has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        initializeNavigation: function() {
          var domain = privlyNetworkService.contentServerDomain();
          $(".home_domain").text(domain.split("/")[2]);
          $(".account_url").attr("href", domain + "/pages/account");
          $(".legal_nav").attr("href", domain + "/pages/privacy");
      Severity: Minor
      Found in shared/javascripts/network_service.js - About 1 hr to fix

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

              Privly.message[test.action]({
                name: test.action,
                action: 'ping',
                data: $('[name="data"]').val()
              }, true).then(appendPongResponse);
        Severity: Major
        Found in Pages/js/message_test.js and 1 other location - About 1 hr to fix
        Pages/js/message_test.js on lines 41..45

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

        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

              Privly.message[test.action]({
                name: test.action,
                action: 'pingAsync',
                data: $('[name="data"]').val()
              }, true).then(appendPongResponse);
        Severity: Major
        Found in Pages/js/message_test.js and 1 other location - About 1 hr to fix
        Pages/js/message_test.js on lines 35..39

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

        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 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 parseDate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            parseDate: function(string, mode) {
          
              var date = new Date(string);
              var current = new Date();
          
          
          Severity: Minor
          Found in History/js/new.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

              Function restoreServer has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function restoreServer(){
                
                var posting_content_server_url = Privly.options.getServerUrl();
                var server_input = document.getElementById("content_server_url");
              
              
              Severity: Minor
              Found in Pages/js/options.js - About 1 hr to fix

                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

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

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

                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

                Function getItem has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                  getItem: function(key) {
                    if ( ls.localStorageDefined ) {
                      var value = localStorage.getItem(key);
                      if (value === null){
                        return undefined;
                Severity: Minor
                Found in shared/javascripts/local_storage.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 getParameterHash has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                  getParameterHash: function(url)
                  {    
                    var parameters = {};
                    var hashIndex = url.indexOf("#");
                    if (hashIndex >= 0) {
                Severity: Minor
                Found in shared/javascripts/parameters.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 platformName has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                  platformName: function() {
                    if (navigator.userAgent.indexOf("iPhone") >= 0 || 
                      navigator.userAgent.indexOf("iPad") >= 0) {
                      if( navigator.userAgent.indexOf("Safari") >= 0 ) { return "HOSTED"; }
                        return "IOS";
                Severity: Minor
                Found in shared/javascripts/network_service.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 processResponseContent has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function processResponseContent(response) {
                  
                  // Change the edit button back to the default style
                  // if it has been modified. This is usually for
                  // when the user has edited content and submitted
                Severity: Minor
                Found in Message/js/controllers/show.js - About 1 hr to fix

                  Function sendMessageTo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    SafariAdapter.prototype.sendMessageTo = function (to, payload) {
                      if (to === 'BACKGROUND_SCRIPT') {
                        if (this.getContextName() === 'BACKGROUND_SCRIPT') {
                          safari.self.contentWindow.postMessage(payload, '*');
                        }
                  Severity: Minor
                  Found in shared/javascripts/context_messenger.js - About 1 hr to fix

                    Function _postCompleted has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      NewAdapter.prototype._postCompleted = function (response, url) {
                        $("#save").prop('disabled', false);
                    
                        if (response.jqXHR.status === 201 && url !== undefined && url !== "") {
                          Privly.message.messageExtension({privlyUrl: url});
                    Severity: Minor
                    Found in shared/javascripts/viewAdapters/new.js - About 1 hr to fix

                      Function setListener has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        SafariAdapter.prototype.setListener = function (callback) {
                          if (this.getContextName() === 'BACKGROUND_SCRIPT') {
                            safari.application.addEventListener("message", function(payload) {
                              if (typeof payload.name !== "undefined" && payload.name === "privlyMessage") {
                                // The message is received from other than BACKGROUND_SCRIPT
                      Severity: Minor
                      Found in shared/javascripts/context_messenger.js - About 1 hr to fix

                        Function sendMessageTo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          FirefoxAdapter.prototype.sendMessageTo = function (to, data) {
                           
                            var contextName = this.getContextName();
                            // Messages from Privly Applications to Background Script, Content Scripts
                            // Privly Applications can't send messages directly to background scripts, they do so via
                        Severity: Minor
                        Found in shared/javascripts/context_messenger.js - About 1 hr to fix

                          Function showDownloadMessage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                            showDownloadMessage: function(callback) {
                          
                              // Show the download extension link in the hosted context
                              if( privlyNetworkService.platformName() === "HOSTED" && !privlyHostPage.isInjected() ){
                          
                          
                          Severity: Minor
                          Found in shared/javascripts/viewAdapters/show.js - About 55 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

                          Severity
                          Category
                          Status
                          Source
                          Language