datahuborg/datahub

View on GitHub
src/browser/views.py

Summary

Maintainability
F
1 wk
Test Coverage

File views.py has 1015 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
import urllib
import uuid
import hashlib

Severity: Major
Found in src/browser/views.py - About 2 days to fix

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

    def app_allow_access(request, app_id, repo_name):
        username = request.user.get_username()
        try:
            app = None
            try:
    Severity: Minor
    Found in src/browser/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 license_view_delete has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def license_view_delete(request, repo_base, repo, table,
    Severity: Minor
    Found in src/browser/views.py - About 45 mins to fix

      Function license_view_create has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def license_view_create(request, repo_base, repo, table, license_id):
      Severity: Minor
      Found in src/browser/views.py - About 35 mins to fix

        Function security_policy_delete has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def security_policy_delete(request, repo_base, repo, table, policy_id):
        Severity: Minor
        Found in src/browser/views.py - About 35 mins to fix

          Function security_policy_edit has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def security_policy_edit(request, repo_base, repo, table, policyid):
          Severity: Minor
          Found in src/browser/views.py - About 35 mins to fix

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

            def license_create(request):
                username = request.user.get_username()
                public_role = settings.PUBLIC_ROLE
            
                if request.method == 'POST':
            Severity: Minor
            Found in src/browser/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

            Avoid too many return statements within this function.
            Open

                    return HttpResponse(
            Severity: Major
            Found in src/browser/views.py - About 30 mins to fix

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

              def user(request, repo_base=None):
                  username = request.user.get_username()
              
                  repo_base = username or 'public'
              
              
              Severity: Minor
              Found in src/browser/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

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

              def app_register(request):
                  username = request.user.get_username()
              
                  if request.method == "POST":
                      try:
              Severity: Minor
              Found in src/browser/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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              @csrf_exempt
              def service_account_binary(request):
                  # Catch CORS preflight requests
                  if request.method == 'OPTIONS':
                      resp = HttpResponse('')
              Severity: Major
              Found in src/browser/views.py and 1 other location - About 1 day to fix
              src/browser/views.py on lines 67..96

              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 211.

              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

              @csrf_exempt
              def service_core_binary(request):
                      # Catch CORS preflight requests
                  if request.method == 'OPTIONS':
                      resp = HttpResponse('')
              Severity: Major
              Found in src/browser/views.py and 1 other location - About 1 day to fix
              src/browser/views.py on lines 99..129

              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 211.

              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

              def repo_files(request, repo_base, repo):
                  '''
                  shows thee files in a repo
                  '''
                  username = request.user.get_username()
              Severity: Major
              Found in src/browser/views.py and 1 other location - About 6 hrs to fix
              src/browser/views.py on lines 284..302

              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 103.

              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

              def repo_cards(request, repo_base, repo):
                  '''
                  shows the cards in a repo
                  '''
                  username = request.user.get_username()
              Severity: Major
              Found in src/browser/views.py and 1 other location - About 6 hrs to fix
              src/browser/views.py on lines 263..281

              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 103.

              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

              @login_required
              def table_clone(request, repo_base, repo, table):
                  username = request.user.get_username()
                  new_table = request.GET.get('var_text', None)
              
              
              Severity: Major
              Found in src/browser/views.py and 1 other location - About 4 hrs to fix
              src/browser/views.py on lines 1026..1035

              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 80.

              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

              @login_required
              def card_export(request, repo_base, repo, card_name):
                  username = request.user.get_username()
                  file_name = request.GET.get('var_text', card_name)
              
              
              Severity: Major
              Found in src/browser/views.py and 1 other location - About 4 hrs to fix
              src/browser/views.py on lines 726..735

              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 80.

              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

              @login_required
              def table_delete(request, repo_base, repo, table_name):
                  """
                  Deletes the given table.
              
              
              Severity: Major
              Found in src/browser/views.py and 1 other location - About 3 hrs to fix
              src/browser/views.py on lines 770..785

              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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              @login_required
              def view_delete(request, repo_base, repo, view_name):
                  """
                  Deletes the given view.
              
              
              Severity: Major
              Found in src/browser/views.py and 1 other location - About 3 hrs to fix
              src/browser/views.py on lines 752..767

              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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              @login_required
              def card_delete(request, repo_base, repo, card_name):
                  username = request.user.get_username()
              
                  with DataHubManager(user=username, repo_base=repo_base) as manager:
              Severity: Major
              Found in src/browser/views.py and 1 other location - About 3 hrs to fix
              src/browser/views.py on lines 834..842

              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 65.

              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

              @login_required
              def file_delete(request, repo_base, repo, file_name):
                  username = request.user.get_username()
              
                  with DataHubManager(user=username, repo_base=repo_base) as manager:
              Severity: Major
              Found in src/browser/views.py and 1 other location - About 3 hrs to fix
              src/browser/views.py on lines 1038..1046

              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 65.

              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 request.method == 'POST':
                      repo = request.POST['repo']
                      with DataHubManager(user=username, repo_base=repo_base) as manager:
                          manager.create_repo(repo)
                      return HttpResponseRedirect(reverse('browser-user', args=(username,)))
              Severity: Major
              Found in src/browser/views.py and 1 other location - About 1 hr to fix
              src/browser/views.py on lines 484..515

              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 44.

              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 request.method == 'POST':
                      # creates a new license
                      pii_anonymized = False
                      pii_removed = False
              
              
              Severity: Major
              Found in src/browser/views.py and 1 other location - About 1 hr to fix
              src/browser/views.py on lines 319..328

              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 44.

              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

                  with DataHubManager(user=username, repo_base=repo_base) as manager:
                      manager.delete_license_view(
              Severity: Minor
              Found in src/browser/views.py and 1 other location - About 45 mins to fix
              src/browser/views.py on lines 538..539

              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 35.

              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

                      with DataHubManager(user=username, repo_base=repo_base) as manager:
                          manager.create_license_view(
              Severity: Minor
              Found in src/browser/views.py and 1 other location - About 45 mins to fix
              src/browser/views.py on lines 579..580

              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 35.

              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 4 locations. Consider refactoring.
              Open

                  collaborators = [c for c in collaborators if c['username']
                                   not in ['', username, settings.PUBLIC_ROLE]]
              Severity: Major
              Found in src/browser/views.py and 3 other locations - About 35 mins to fix
              src/browser/views.py on lines 359..360
              src/browser/views.py on lines 389..390
              src/browser/views.py on lines 549..550

              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 33.

              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 4 locations. Consider refactoring.
              Open

                      collaborators = [c for c in collaborators if c['username']
                                       not in ['', username, settings.PUBLIC_ROLE]]
              Severity: Major
              Found in src/browser/views.py and 3 other locations - About 35 mins to fix
              src/browser/views.py on lines 359..360
              src/browser/views.py on lines 389..390
              src/browser/views.py on lines 466..467

              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 33.

              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 4 locations. Consider refactoring.
              Open

                  collaborators = [c for c in collaborators if c['username']
                                   not in ['', username, settings.PUBLIC_ROLE]]
              Severity: Major
              Found in src/browser/views.py and 3 other locations - About 35 mins to fix
              src/browser/views.py on lines 359..360
              src/browser/views.py on lines 466..467
              src/browser/views.py on lines 549..550

              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 33.

              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 4 locations. Consider refactoring.
              Open

                  collaborators = [c for c in collaborators if c['username']
                                   not in ['', username, settings.PUBLIC_ROLE]]
              Severity: Major
              Found in src/browser/views.py and 3 other locations - About 35 mins to fix
              src/browser/views.py on lines 389..390
              src/browser/views.py on lines 466..467
              src/browser/views.py on lines 549..550

              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 33.

              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

              Do not use bare 'except'
              Open

                  except:
              Severity: Minor
              Found in src/browser/views.py by pep8

              When catching exceptions, mention specific exceptions when possible.

              Okay: except Exception:
              Okay: except BaseException:
              E722: except:

              Too many blank lines (2)
              Open

                  with DataHubManager(user=username, repo_base=repo_base) as manager:
              Severity: Minor
              Found in src/browser/views.py by pep8

              Separate top-level function and class definitions with two blank lines.

              Method definitions inside a class are separated by a single blank
              line.
              
              Extra blank lines may be used (sparingly) to separate groups of
              related functions.  Blank lines may be omitted between a bunch of
              related one-liners (e.g. a set of dummy implementations).
              
              Use blank lines in functions, sparingly, to indicate logical
              sections.
              
              Okay: def a():\n    pass\n\n\ndef b():\n    pass
              Okay: def a():\n    pass\n\n\nasync def b():\n    pass
              Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
              Okay: default = 1\nfoo = 1
              Okay: classify = 1\nfoo = 1
              
              E301: class Foo:\n    b = 0\n    def bar():\n        pass
              E302: def a():\n    pass\n\ndef b(n):\n    pass
              E302: def a():\n    pass\n\nasync def b(n):\n    pass
              E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
              E303: def a():\n\n\n\n    pass
              E304: @decorator\n\ndef a():\n    pass
              E305: def a():\n    pass\na()
              E306: def a():\n    def b():\n        pass\n    def c():\n        pass

              Expected 2 blank lines after class or function definition, found 1
              Open

              '''
              Severity: Minor
              Found in src/browser/views.py by pep8

              Separate top-level function and class definitions with two blank lines.

              Method definitions inside a class are separated by a single blank
              line.
              
              Extra blank lines may be used (sparingly) to separate groups of
              related functions.  Blank lines may be omitted between a bunch of
              related one-liners (e.g. a set of dummy implementations).
              
              Use blank lines in functions, sparingly, to indicate logical
              sections.
              
              Okay: def a():\n    pass\n\n\ndef b():\n    pass
              Okay: def a():\n    pass\n\n\nasync def b():\n    pass
              Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
              Okay: default = 1\nfoo = 1
              Okay: classify = 1\nfoo = 1
              
              E301: class Foo:\n    b = 0\n    def bar():\n        pass
              E302: def a():\n    pass\n\ndef b(n):\n    pass
              E302: def a():\n    pass\n\nasync def b(n):\n    pass
              E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
              E303: def a():\n\n\n\n    pass
              E304: @decorator\n\ndef a():\n    pass
              E305: def a():\n    pass\na()
              E306: def a():\n    def b():\n        pass\n    def c():\n        pass

              Do not use bare 'except'
              Open

                  except:
              Severity: Minor
              Found in src/browser/views.py by pep8

              When catching exceptions, mention specific exceptions when possible.

              Okay: except Exception:
              Okay: except BaseException:
              E722: except:

              Do not use bare 'except'
              Open

                  except:
              Severity: Minor
              Found in src/browser/views.py by pep8

              When catching exceptions, mention specific exceptions when possible.

              Okay: except Exception:
              Okay: except BaseException:
              E722: except:

              Over-indented (comment)
              Open

                      # Catch CORS preflight requests
              Severity: Minor
              Found in src/browser/views.py by pep8

              Use indent_size (PEP8 says 4) spaces per indentation level.

              For really old code that you don't want to mess up, you can continue
              to use 8-space tabs.
              
              Okay: a = 1
              Okay: if a == 0:\n    a = 1
              E111:   a = 1
              E114:   # a = 1
              
              Okay: for item in items:\n    pass
              E112: for item in items:\npass
              E115: for item in items:\n# Hi\n    pass
              
              Okay: a = 1\nb = 2
              E113: a = 1\n    b = 2
              E116: a = 1\n    # b = 2

              There are no issues that match your filters.

              Category
              Status