Showing 40 of 40 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
e('div', null,
[
e('i',
{ class: `icon ${this.state.lengthValidationColor}` },
null),
- 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 68.
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 frequency
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def frequency(request):
"""Returns the frequency of the given word."""
if request.is_ajax():
if request.method == 'POST':
text = json.loads(request.body.decode('utf-8'))
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (block.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode
.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.display != "none") {
// we make sure we get only text and not GistCreateCode code
if (block.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode
.parentNode.parentNode.parentNode.children[0].children[2].children[0].innerHTML != "Code") {
- 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 66.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (block.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode
.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.display != "none") {
// we make sure we get only text and not GistCreateCode code
if (block.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode
.parentNode.parentNode.parentNode.parentNode.children[0].children[2].children[0].innerHTML != "Code") {
- 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 66.
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 check_internal_links
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def check_internal_links(request):
"""Returns a code telling if the article has enough internal links."""
if request.is_ajax():
if request.method == 'POST':
text = json.loads(request.body.decode('utf-8'))
- 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
if (data["response"] == 'VALID_SLUG') {
this.setState({ slugValidationColor: "green", urlScore: 1 });
} else {
this.setState({ slugValidationColor: "red", urlScore: 0 });
}
- 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 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
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (data["response"] == 'VALID_TITLE') {
this.setState({ titleValidationColor: "green", titleScore: 1 });
} else {
this.setState({ titleValidationColor: "red", titleScore: 0 });
}
- 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 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
- 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 getText
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
getText() {
let blocks = document.getElementsByClassName("notranslate public-DraftEditor-content");
let text = "";
for (let block of blocks) {
// we make sure we don’t get deleted blocks’s content
Function check_h1_in_content
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
check_h1_in_content() {
var rich_text_blocks = document.getElementsByClassName("DraftEditor-root");
var text;
for (let block of rich_text_blocks) {
text += block.innerHTML;
Function checkTitle
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
checkTitle() {
var body = [];
body[0] = document.getElementById("id_keyword").value;
body[1] = document.getElementById("id_title").value;
fetch("/seo/title/", {
Function checkLength
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
checkLength() {
fetch("/seo/length/", {
method: "POST",
credentials: 'include',
body: JSON.stringify(this.getText()),
Function checkInternalLinks
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
checkInternalLinks() {
fetch("/seo/internal_links/", {
method: "POST",
credentials: 'include',
body: JSON.stringify(this.getHtml()),
Function check_title_in_article
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def check_title_in_article(request):
"""Check there are no h1 in the content of the article"""
if request.is_ajax():
if request.method == 'POST':
text = json.loads(request.body.decode('utf-8'))
- 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
Avoid deeply nested control flow statements. Open
if (!line.classList.contains('Draftail-block--atomic')) {
if (line.classList.contains('public-DraftStyleDefault-ol')
|| line.classList.contains('public-DraftStyleDefault-ul')) {
for (let child of line.children) {
text += " " + child.firstChild.firstChild.firstChild.innerHTML;
Function getCookie
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function getCookie(name) {
let cookieValue = null;
if (document.cookie && document.cookie !== '') {
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
- 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
Avoid too many return
statements within this function. Open
return ERROR_JSON
Avoid too many return
statements within this function. Open
return JsonResponse({"response": "VALID_SLUG"})
Avoid too many return
statements within this function. Open
return ERROR_JSON
Avoid too many return
statements within this function. Open
return ERROR_JSON
Avoid too many return
statements within this function. Open
return JsonResponse({"response": "VALID_TITLE", "keyword_present": is_keyword_present, "character_count": title_character_count, "word_count": title_word_count})