trileg/WebTeX

View on GitHub
WebTeX/static/js/main.js

Summary

Maintainability
D
2 days
Test Coverage

Function compile has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function compile() {
  if (cwd !== "") {
    // エディタのテキストを読み出し,JSONに
    // これをpythonに投げて,コンパイルリザルト,ログを受け取る
    // コンパイルに成功すれば,PDFファイルをindex.htmlに追加する
Severity: Minor
Found in WebTeX/static/js/main.js - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File main.js has 260 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var editor;
var cwd = "";

$(window).load(init());

Severity: Minor
Found in WebTeX/static/js/main.js - About 2 hrs to fix

    Function compile has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function compile() {
      if (cwd !== "") {
        // エディタのテキストを読み出し,JSONに
        // これをpythonに投げて,コンパイルリザルト,ログを受け取る
        // コンパイルに成功すれば,PDFファイルをindex.htmlに追加する
    Severity: Minor
    Found in WebTeX/static/js/main.js - About 1 hr to fix

      Function readFilelist has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function readFilelist(directoryItem) {
        var json = JSON.stringify({
          "_csrf_token": $("#_csrf_token").val()
        });
      
      
      Severity: Minor
      Found in WebTeX/static/js/main.js - About 1 hr to fix

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

        function init() {
          editor = ace.edit("editor");
          readDirectory($("#username").text());
        
          $("#createDirectory").click(function () {
        Severity: Minor
        Found in WebTeX/static/js/main.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 readDirectory has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function readDirectory() {
          var json = JSON.stringify({
            "_csrf_token": $("#_csrf_token").val()
          });
        
        
        Severity: Minor
        Found in WebTeX/static/js/main.js - About 1 hr to fix

          Function readFilelist has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function readFilelist(directoryItem) {
            var json = JSON.stringify({
              "_csrf_token": $("#_csrf_token").val()
            });
          
          
          Severity: Minor
          Found in WebTeX/static/js/main.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 success has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              success: function (data) {
                $("#filelist").empty();
                var result = JSON.parse(data.ResultSet).result;
                if (result !== "Failure") {
                  $("#cwd").text(cwd);
          Severity: Minor
          Found in WebTeX/static/js/main.js - About 1 hr to fix

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

            function init() {
              editor = ace.edit("editor");
              readDirectory($("#username").text());
            
              $("#createDirectory").click(function () {
            Severity: Minor
            Found in WebTeX/static/js/main.js - About 1 hr to fix

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

                  success: function (data) {
                    $("#directorylist").empty();
                    $("#directorylist").append(
                        "<li><a data-toggle='modal' href='#createDirectoryModal'>Create directory</a></li>"
                    );
              Severity: Minor
              Found in WebTeX/static/js/main.js - About 1 hr to fix

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

                function setDirectory(directoryItem) {
                  var json = JSON.stringify({
                    "name": directoryItem,
                    "_csrf_token": $("#_csrf_token").val()
                  });
                Severity: Minor
                Found in WebTeX/static/js/main.js - About 1 hr to fix

                  Function setDirectory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function setDirectory(directoryItem) {
                    var json = JSON.stringify({
                      "name": directoryItem,
                      "_csrf_token": $("#_csrf_token").val()
                    });
                  Severity: Minor
                  Found in WebTeX/static/js/main.js - About 25 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Function removeDirectory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function removeDirectory(directoryItem) {
                    if (!confirm("Remove directory: "+escapeHTML(directoryItem)+"\nAre you sure?")) {
                      return false;
                    } else {
                      var json = JSON.stringify({
                  Severity: Minor
                  Found in WebTeX/static/js/main.js - About 25 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

                  Unexpected alert.
                  Open

                            alert("Failed to remove directory");
                  Severity: Minor
                  Found in WebTeX/static/js/main.js by eslint

                  Disallow Use of Alert (no-alert)

                  JavaScript's alert, confirm, and prompt functions are widely considered to be obtrusive as UI elements and should be replaced by a more appropriate custom UI implementation. Furthermore, alert is often used while debugging code, which should be removed before deployment to production.

                  alert("here!");

                  Rule Details

                  This rule is aimed at catching debugging code that should be removed and popup UI elements that should be replaced with less obtrusive, custom UIs. As such, it will warn when it encounters alert, prompt, and confirm function calls which are not shadowed.

                  Examples of incorrect code for this rule:

                  /*eslint no-alert: "error"*/
                  
                  alert("here!");
                  
                  confirm("Are you sure?");
                  
                  prompt("What's your name?", "John Doe");

                  Examples of correct code for this rule:

                  /*eslint no-alert: "error"*/
                  
                  customAlert("Something happened!");
                  
                  customConfirm("Are you sure?");
                  
                  customPrompt("Who are you?");
                  
                  function foo() {
                      var alert = myCustomLib.customAlert;
                      alert();
                  }

                  Related Rules

                  Unexpected confirm.
                  Open

                    if (!confirm("Remove directory: "+escapeHTML(directoryItem)+"\nAre you sure?")) {
                  Severity: Minor
                  Found in WebTeX/static/js/main.js by eslint

                  Disallow Use of Alert (no-alert)

                  JavaScript's alert, confirm, and prompt functions are widely considered to be obtrusive as UI elements and should be replaced by a more appropriate custom UI implementation. Furthermore, alert is often used while debugging code, which should be removed before deployment to production.

                  alert("here!");

                  Rule Details

                  This rule is aimed at catching debugging code that should be removed and popup UI elements that should be replaced with less obtrusive, custom UIs. As such, it will warn when it encounters alert, prompt, and confirm function calls which are not shadowed.

                  Examples of incorrect code for this rule:

                  /*eslint no-alert: "error"*/
                  
                  alert("here!");
                  
                  confirm("Are you sure?");
                  
                  prompt("What's your name?", "John Doe");

                  Examples of correct code for this rule:

                  /*eslint no-alert: "error"*/
                  
                  customAlert("Something happened!");
                  
                  customConfirm("Are you sure?");
                  
                  customPrompt("Who are you?");
                  
                  function foo() {
                      var alert = myCustomLib.customAlert;
                      alert();
                  }

                  Related Rules

                  Unexpected alert.
                  Open

                            alert("Successfully removed directory");
                  Severity: Minor
                  Found in WebTeX/static/js/main.js by eslint

                  Disallow Use of Alert (no-alert)

                  JavaScript's alert, confirm, and prompt functions are widely considered to be obtrusive as UI elements and should be replaced by a more appropriate custom UI implementation. Furthermore, alert is often used while debugging code, which should be removed before deployment to production.

                  alert("here!");

                  Rule Details

                  This rule is aimed at catching debugging code that should be removed and popup UI elements that should be replaced with less obtrusive, custom UIs. As such, it will warn when it encounters alert, prompt, and confirm function calls which are not shadowed.

                  Examples of incorrect code for this rule:

                  /*eslint no-alert: "error"*/
                  
                  alert("here!");
                  
                  confirm("Are you sure?");
                  
                  prompt("What's your name?", "John Doe");

                  Examples of correct code for this rule:

                  /*eslint no-alert: "error"*/
                  
                  customAlert("Something happened!");
                  
                  customConfirm("Are you sure?");
                  
                  customPrompt("Who are you?");
                  
                  function foo() {
                      var alert = myCustomLib.customAlert;
                      alert();
                  }

                  Related Rules

                  There are no issues that match your filters.

                  Category
                  Status