trileg/WebTeX

View on GitHub

Showing 47 of 47 total issues

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

def read_filelist():
    if not check_csrf(request, 'json'):
        abort(403)

    dictionary = {}
Severity: Minor
Found in WebTeX/app.py - 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

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

    shutil.rmtree(storage + session['username'] + '/' + request.json['name'])
Severity: Major
Found in WebTeX/app.py and 1 other location - About 1 hr to fix
WebTeX/app.py on lines 213..213

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

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

      def save_config():
          if not check_csrf(request, 'json'):
              abort(403)
      
          dictionary = {}
      Severity: Minor
      Found in WebTeX/app.py - 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 readConfig has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

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

              Avoid too many return statements within this function.
              Open

                  return
              Severity: Major
              Found in WebTeX/app.py - About 30 mins to fix

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

                function readConfig() {
                  var json = JSON.stringify({
                    "_csrf_token": $("#_csrf_token").val()
                  });
                
                
                Severity: Minor
                Found in WebTeX/static/js/preference.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 read_directory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def read_directory():
                    if not check_csrf(request, 'json'):
                        abort(403)
                
                    dictionary = {}
                Severity: Minor
                Found in WebTeX/app.py - 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 compile_tex has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def compile_tex():
                    if not check_csrf(request, 'json'):
                        abort(403)
                
                    dictionary = {}
                Severity: Minor
                Found in WebTeX/app.py - 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 is_account_valid has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def is_account_valid():
                    username = request.form['username']
                    config = configparser.ConfigParser()
                    config.read(conf)
                
                
                Severity: Minor
                Found in WebTeX/app.py - 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 set_directory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def set_directory():
                    if not check_csrf(request, 'json'):
                        abort(403)
                
                    dictionary = {}
                Severity: Minor
                Found in WebTeX/app.py - 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 upload_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def upload_file():
                    if not check_csrf(request, 'form'):
                        abort(403)
                
                    dictionary = {}
                Severity: Minor
                Found in WebTeX/app.py - 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 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

                Rule doesn't have all its properties in alphabetical order.
                Open

                #main-col {
                Severity: Minor
                Found in WebTeX/static/css/redpen.css by csslint

                Rule doesn't have all its properties in alphabetical order.
                Open

                html,body,.container-fluid {
                Severity: Minor
                Found in WebTeX/static/css/redpen.css by csslint

                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

                Severity
                Category
                Status
                Source
                Language