vmesel/PyJobs

View on GitHub

Showing 18 of 76 total issues

File test_job_views.py has 504 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from unittest.mock import patch

from django.contrib.auth.models import User
from django.http import HttpRequest
from django.test import Client, TestCase, override_settings
Severity: Major
Found in pyjobs/core/tests/test_job_views.py - About 1 day to fix

    File test_job_model.py has 283 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from datetime import datetime, timedelta
    from hashlib import sha512
    from unittest.mock import patch
    import responses
    from django.contrib.auth.models import User
    Severity: Minor
    Found in pyjobs/core/tests/test_job_model.py - About 2 hrs to fix

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

          def process_response(self, request, response):
              response["Cache-Control"] = "max-age=%d" % MAX_AGE
              if response.status_code != 404:
                  return response
      
      
      Severity: Minor
      Found in pyjobs/middleware.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 subscribe has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function subscribe(reg) {
        // Get the Subscription or register one
        reg.pushManager.getSubscription().then(
          function(subscription) {
            var metaObj, applicationServerKey, options;
      Severity: Minor
      Found in pyjobs/staticfiles/webpush/webpush.js - About 1 hr to fix

        Function unsubscribe has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function unsubscribe(reg) {
          // Get the Subscription to unregister
          reg.pushManager.getSubscription()
            .then(
              function(subscription) {
        Severity: Minor
        Found in pyjobs/staticfiles/webpush/webpush.js - About 1 hr to fix

          Function handle has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def handle(self, *args, **options):
                  if not settings.GITHUB_ACCESS_TOKEN or not settings.GITHUB_DEFAULT_REPO:
                      return "False"
          
                  g = Github(settings.GITHUB_ACCESS_TOKEN)
          Severity: Minor
          Found in pyjobs/synchronizer/management/commands/load_jobs_from_github.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 initialiseState has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function initialiseState(reg) {
              // Are Notifications supported in the service worker?  
              if (!(reg.showNotification)) {
                  // Show a message and activate the button
                  subBtn.textContent = document.getElementById('push-subscribe').getAttribute("data-push-subscribe-label");
          Severity: Minor
          Found in pyjobs/staticfiles/webpush/webpush.js - About 1 hr to fix

            Function section_reshaping has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def section_reshaping(sections, issue_content):
                """
                This function enables markdown <h2> to be detected and inserted
                in the right section of the original dictionary.
            
            
            Severity: Minor
            Found in pyjobs/synchronizer/management/commands/load_jobs_from_github.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

            Function setup_labels has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def setup_labels(labels, content):
                content["salary_range"] = 10
                content["contract_form"] = 1
                content["job_level"] = 5
                content["remote"] = False
            Severity: Minor
            Found in pyjobs/synchronizer/management/commands/load_jobs_from_github.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

            Function format_issue_content has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def format_issue_content(issue_content):
                sections = {
                    "Nossa empresa": "",
                    "Descrição da vaga": "",
                    "Local": "",
            Severity: Minor
            Found in pyjobs/synchronizer/management/commands/load_jobs_from_github.py - About 45 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 handle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def handle(self, *args, **options):
            
                    for user in tqdm(User.objects.exclude(profile__github__isnull=True)):
                        user_data = {
                            "github": {
            Severity: Minor
            Found in pyjobs/profiler/management/commands/github_user_stats.py - About 45 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 test has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            def test(sender, instance, created, **kwargs):
                if not created or not instance.receive_emails:
                    return False
            
                message_text = " ".join(
            Severity: Minor
            Found in pyjobs/marketing/triggers.py - 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

            Function job_view has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            def job_view(request, unique_slug):
                job = get_object_or_404(Job, unique_slug=unique_slug)
                context = {
                    "job": job,
                    "logged_in": False,
            Severity: Minor
            Found in pyjobs/core/views.py - 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

            Function handle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def handle(self, *args, **options):
                    driver = driver_factory()
            
                    for user in tqdm(
                        User.objects.filter(profile__linkedin__isnull=False).exclude(
            Severity: Minor
            Found in pyjobs/profiler/management/commands/linkedin_user_stats.py - 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

            Function handle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def handle(self, *args, **options):
                    headers = {
                        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS 11.1.0; rv:42.0) Gecko/20100101 Firefox/42.0"
                    }
                    response = requests.get(
            Severity: Minor
            Found in pyjobs/synchronizer/management/commands/load_jobs_from_remoteok.py - 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 redirect("/")
            Severity: Major
            Found in pyjobs/middleware.py - About 30 mins to fix

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

              def append_social_info_to_context(request):
                  return_content = {}
              
                  try:
                      user = request.user
              Severity: Minor
              Found in pyjobs/core/context_processors.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 pythonista_change_password has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def pythonista_change_password(request):
                  template_name = "user_area/pythonistas-area-password-change.html"
                  if request.user.has_usable_password():
                      form = PasswordChangeForm
                  else:
              Severity: Minor
              Found in pyjobs/core/views.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

              Severity
              Category
              Status
              Source
              Language