privly/privly-applications

View on GitHub

Showing 109 of 109 total issues

Function contentReturned has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  contentReturned: function(response, callback) {
    if( response.jqXHR.status === 200 ) {
      
      var json = response.json;
      
Severity: Minor
Found in shared/javascripts/viewAdapters/show.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 tooltip has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    tooltip: function(){

      // Create a new glyph if needed
      if (Privly.options.getGlyph() === null) {
        privlyTooltip.generateNewGlyph();
Severity: Minor
Found in shared/javascripts/tooltip.js - About 1 hr to fix

    Function pendingContent has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      pendingContent: function(callback) {
    
        // Show prompt to download extension, if in the hosted environment
        callbacks.showDownloadMessage();
    
    
    Severity: Minor
    Found in shared/javascripts/viewAdapters/show.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 isWhitelistedDomain has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      isWhitelistedDomain: function(url) {
        
        // Chrome maintains an explicit whitelist in local storage
        if( privlyNetworkService.platformName() === "CHROME" || 
          privlyNetworkService.platformName() === "FIREFOX") {
    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 isDomainValid has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      Privly.options.isDomainValid = function (domain) {
        // Each subdomain can be from 1-63 characters and may contain alphanumeric
        // characters, - and _ but may not begin or end with - or _
        // Each domain can be from 1-63 characters and may contain alphanumeric 
        // characters and - but may not begin or end with - Each top level domain may
    Severity: Minor
    Found in shared/javascripts/options.js - About 1 hr to fix

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

      function previewMarkdown() {
        $( "#post_content" ).html(markdown.toHTML($( "#edit_text" ).val()));
        $( "#update" ).attr("class", "btn btn-warning");
        privlyHostPage.resizeToWrapper();
      }
      Severity: Major
      Found in Message/js/controllers/show.js and 1 other location - About 1 hr to fix
      PlainPost/js/controllers/show.js on lines 17..21

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

      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.options.getWhitelistRegExp = function () {
          var v = Privly.storage.get('options/whitelist/regexp');
          if (v === null) {
            v = '';
          }
      Severity: Major
      Found in shared/javascripts/options.js and 1 other location - About 1 hr to fix
      shared/javascripts/options.js on lines 341..347

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

      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

      function previewMarkdown() {
        $( "#post_content" ).html(markdown.toHTML($( "#edit_text" ).val()));
        $( "#update" ).attr("class", "btn btn-warning");
        privlyHostPage.resizeToWrapper();
      }
      Severity: Major
      Found in PlainPost/js/controllers/show.js and 1 other location - About 1 hr to fix
      Message/js/controllers/show.js on lines 25..29

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

      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.options.getServerUrl = function () {
          var v = Privly.storage.get('options/contentServer/url');
          if (v === null) {
            v = 'https://privlyalpha.org';
          }
      Severity: Major
      Found in shared/javascripts/options.js and 1 other location - About 1 hr to fix
      shared/javascripts/options.js on lines 300..306

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

      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.options.isInjectionEnabled = function () {
          var v = Privly.storage.get('options/injection');
          if (v === null) {
            v = true;
          }
      Severity: Major
      Found in shared/javascripts/options.js and 1 other location - About 1 hr to fix
      shared/javascripts/options.js on lines 180..186

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

      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.options.isPrivlyButtonEnabled = function () {
          var v = Privly.storage.get('options/privlyButton');
          if (v === null) {
            v = false;
          }
      Severity: Major
      Found in shared/javascripts/options.js and 1 other location - About 1 hr to fix
      shared/javascripts/options.js on lines 205..211

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

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

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

          function previewMarkdown() {
            var preview = document.getElementById("preview");
            var mkdwn = document.getElementById("content").value;
            preview.innerHTML = markdown.toHTML(mkdwn);
          }
        Severity: Major
        Found in PlainPost/js/controllers/new.js and 1 other location - About 1 hr to fix
        Message/js/controllers/new.js on lines 29..33

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

        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

          function previewMarkdown() {
            var preview = document.getElementById("preview");
            var mkdwn = document.getElementById("content").value;
            preview.innerHTML = markdown.toHTML(mkdwn);
          }
        Severity: Major
        Found in Message/js/controllers/new.js and 1 other location - About 1 hr to fix
        PlainPost/js/controllers/new.js on lines 12..16

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

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

          click: function(evt, callback) {
            
            if( ! privlyNetworkService.permissions.canUpdate ) {
              callbacks.singleClick(evt, callback);
              return;
        Severity: Minor
        Found in shared/javascripts/viewAdapters/show.js - About 1 hr to fix

          Function initMenu has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            SeamlessTTLSelectAdapter.prototype.initMenu = function (isAboveButton, selectedTTLValue, callback) {
              $('#menu').empty();
              this.getTTLOptions()
                .then(function (options) {
                  var i;
          Severity: Minor
          Found in shared/javascripts/viewAdapters/seamless_ttlselect.js - About 1 hr to fix

            Function getGlyphDOM has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              Privly.glyph.getGlyphDOM = function (size) {
                if (size === undefined) {
                  size = 30;
                }
                // Generate a new glyph if not exist
            Severity: Minor
            Found in shared/javascripts/glyph.js - About 1 hr to fix

              Function parseDate has a Cognitive Complexity of 11 (exceeds 5 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

              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 click has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                click: function(evt, callback) {
                  
                  if( ! privlyNetworkService.permissions.canUpdate ) {
                    callbacks.singleClick(evt, callback);
                    return;
              Severity: Minor
              Found in shared/javascripts/viewAdapters/show.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 saveWhitelist has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function saveWhitelist() {
                var url_inputs = document.getElementsByClassName('whitelist_url');
                
                var domains = [];  // Stores whitelist inputs and whitelisted values
                var input_fields = [];
              Severity: Minor
              Found in Pages/js/options.js - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language