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 = {}
- Read upRead up
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'])
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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);
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 () {
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 = {}
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>"
);
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()
});
Function readConfig
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function readConfig() {
var json = JSON.stringify({
"_csrf_token": $("#_csrf_token").val()
});
Avoid too many return
statements within this function. Open
return
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()
});
- Read upRead up
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 = {}
- Read upRead up
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 = {}
- Read upRead up
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)
- Read upRead up
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 = {}
- Read upRead up
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 = {}
- Read upRead up
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()
});
- Read upRead up
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({
- Read upRead up
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 {
- Exclude checks
Rule doesn't have all its properties in alphabetical order. Open
html,body,.container-fluid {
- Exclude checks
Unexpected alert. Open
alert("Successfully removed directory");
- Read upRead up
- Exclude checks
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
- [no-console](no-console.md)
- [no-debugger](no-debugger.md) Source: http://eslint.org/docs/rules/