itarverne/checklist-seo

View on GitHub

Showing 24 of 40 total issues

File seoSidePannel.js has 432 lines of code (exceeds 250 allowed). Consider refactoring.
Open

document.addEventListener('DOMContentLoaded', function () {

    var e = React.createElement;
    sidePannel = document.createElement('div');
    sidePannel.classList.add("seo_side_pannel")
Severity: Minor
Found in seo/static/js/seoSidePannel.js - About 6 hrs to fix

    TestApi has 45 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class TestApi:
    
        # frequency tests
    
        def test_frequency_not_ajax(self):
    Severity: Minor
    Found in seo/testing/test_api.py - About 6 hrs to fix

      Function check_keyword has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

      def check_keyword(request):
          """Checks if the Keyword is valid"""
          if request.is_ajax():
              if request.method == 'POST':
                  data = json.loads(request.body.decode('utf-8'))
      Severity: Minor
      Found in seo/views.py - About 3 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

      Function constructor has 80 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              constructor(props) {
                  super(props);
                  this.state = {
                      keywordScore: 0,
                      lengthScore: 0,
      Severity: Major
      Found in seo/static/js/seoSidePannel.js - About 3 hrs to fix

        Function render has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                render() {
                    return [
                        e('div', { class: "seo-title" },
                            [
                                e('img', { class: 'seo-logo', src: '/static/images/seo_logo.png', alt: "logo seo" },
        Severity: Major
        Found in seo/static/js/seoSidePannel.js - About 2 hrs to fix

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

          def check_title(request):
              """Check if the title is valid"""
              if request.is_ajax():
                  if request.method == 'POST':
                      data = json.loads(request.body.decode('utf-8'))
          Severity: Minor
          Found in seo/views.py - 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

          Function check_slug has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

          def check_slug(request):
              """Check if the slug is valid"""
              if request.is_ajax():
                  if request.method == 'POST':
                      data = 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

          Function article_length has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

          def article_length(request):
              """Returns a code telling if the article is of appropriate length regarding seo rules."""
              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

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

                  checkKeyword() {
                      let body = [];
                      body[0] = document.getElementById("id_keyword").value;
                      body[1] = this.getText();
                      fetch("/seo/keyword/", {
          Severity: Minor
          Found in seo/static/js/seoSidePannel.js - About 1 hr to fix

            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

            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

            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 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 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 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
                          Severity
                          Category
                          Status
                          Source
                          Language