itarverne/checklist-seo

View on GitHub

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),
Severity: Major
Found in seo/static/js/seoSidePannel.js and 1 other location - About 1 hr to fix
seo/static/js/seoSidePannel.js on lines 423..429

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

Further Reading

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'))
Severity: Minor
Found in seo/views.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

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") {
Severity: Major
Found in seo/static/js/seoSidePannel.js and 1 other location - About 1 hr to fix
seo/static/js/seoSidePannel.js on lines 107..134

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

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") {
Severity: Major
Found in seo/static/js/seoSidePannel.js and 1 other location - About 1 hr to fix
seo/static/js/seoSidePannel.js on lines 144..151

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

Further Reading

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'))
Severity: Minor
Found in seo/views.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

                if (data["response"] == 'VALID_SLUG') {
                    this.setState({ slugValidationColor: "green", urlScore: 1 });
                } else {
                    this.setState({ slugValidationColor: "red", urlScore: 0 });
                }
Severity: Major
Found in seo/static/js/seoSidePannel.js and 1 other location - About 1 hr to fix
seo/static/js/seoSidePannel.js on lines 284..288

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

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 });
                }
Severity: Major
Found in seo/static/js/seoSidePannel.js and 1 other location - About 1 hr to fix
seo/static/js/seoSidePannel.js on lines 309..313

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 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
Severity: Minor
Found in seo/static/js/seoSidePannel.js - About 1 hr to fix

    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;
    Severity: Minor
    Found in seo/static/js/seoSidePannel.js - About 1 hr to fix

      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/", {
      Severity: Minor
      Found in seo/static/js/seoSidePannel.js - About 1 hr to fix

        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()),
        Severity: Minor
        Found in seo/static/js/seoSidePannel.js - About 1 hr to fix

          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()),
          Severity: Minor
          Found in seo/static/js/seoSidePannel.js - About 1 hr to fix

            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'))
            Severity: Minor
            Found in seo/views.py - About 55 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

            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;
            Severity: Major
            Found in seo/static/js/seoSidePannel.js - About 45 mins to fix

              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++) {
              Severity: Minor
              Found in seo/static/js/helper.js - About 35 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

              Avoid too many return statements within this function.
              Open

                  return ERROR_JSON
              Severity: Major
              Found in seo/views.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return JsonResponse({"response": "VALID_SLUG"})
                Severity: Major
                Found in seo/views.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return ERROR_JSON
                  Severity: Major
                  Found in seo/views.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return ERROR_JSON
                    Severity: Major
                    Found in seo/views.py - About 30 mins to fix

                      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})
                      Severity: Major
                      Found in seo/views.py - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language