datahuborg/datahub

View on GitHub

Showing 1,132 of 1,132 total issues

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

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

        outcomes = {
            'create_valid': PermissionDenied,
            'create_invalid': ValueError,
            'repo_list': ['full1'] + self.public_repos,
            'collaborator_repo_list': collaborator_repos,
Severity: Major
Found in src/integration_tests/test_manager.py and 1 other location - About 1 hr to fix
src/integration_tests/test_manager.py on lines 179..195

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

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

        outcomes = {
            'create_valid': PermissionDenied,
            'create_invalid': ValueError,
            'repo_list': ['full1'] + self.public_repos,
            'collaborator_repo_list': collaborator_repos,
Severity: Major
Found in src/integration_tests/test_manager.py and 1 other location - About 1 hr to fix
src/integration_tests/test_manager.py on lines 213..229

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

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 update_security_policy(self, policy_id, new_policy, new_policy_type,
                               new_grantee):
        '''
        Updates an existing security policy based on the inputs specified
        by the user.
Severity: Major
Found in src/core/db/backend/pg.py and 1 other location - About 1 hr to fix
src/core/db/backend/pg.py on lines 988..1001

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

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 create_license(
            self, license_name, pii_def, pii_anonymized, pii_removed):
        '''
        Creates a new license
        '''
Severity: Major
Found in src/core/db/backend/pg.py and 1 other location - About 1 hr to fix
src/core/db/backend/pg.py on lines 1258..1271

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

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 find_and_insert has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      function find_and_insert(path, x, y) {
        var prev = null;
        var insertidx = null;
        var dir = (path.length == 1)? null : ((path[0][0] < path[path.length-1][0])? 'inc' : 'dec');
        for (var idx = 0; idx < path.length; idx++) {
Severity: Minor
Found in src/browser/static/dbwipes/js/summary/drawingview.js - About 1 hr to fix

    Function find_and_insert has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          function find_and_insert(path, x, y) {
            var prev = null;
            var insertidx = null;
            var dir = (path.length == 1)? null : ((path[0][0] < path[path.length-1][0])? 'inc' : 'dec');
            for (var idx = 0; idx < path.length; idx++) {
    Severity: Minor
    Found in src/apps/dbwipes/static/js/summary/drawingview.js - About 1 hr to fix

      Cyclomatic complexity is too high in function where_to_sql. (11)
      Open

      def where_to_sql(where_json, negate=False):
          is_type = lambda s, types: any([t in s for t in types])
          l = []
          args = []
          for clause_json in where_json:
      Severity: Minor
      Found in src/apps/dbwipes/util.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in function analyze_input_structure. (11)
      Open

      def analyze_input_structure(i_chunks, o_fields_structure):
        i_chunks_types = [chunk[0] for chunk in i_chunks]
        extracted_fields = {}
        o_fields_types = []
        field_matches = defaultdict(list)
      Severity: Minor
      Found in src/apps/refiner/distill/inference.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method find_security_policies. (11)
      Open

          @staticmethod
          def find_security_policies(repo_base, repo=None, table=None,
                                     policy_id=None, policy=None, policy_type=None,
                                     grantee=None, grantor=None, safe=True):
              '''
      Severity: Minor
      Found in src/core/db/rlsmanager.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in function extract_fields. (11)
      Open

      def extract_fields(o_chunks, o_fields_structure):
        extracted_fields = {}
        o_chunks_types = [chunk[0] for chunk in o_chunks]
        o_fields_types = []
        field_matches = defaultdict(list)
      Severity: Minor
      Found in src/apps/refiner/distill/inference.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method apply_row_level_security_insert. (11)
      Open

          def apply_row_level_security_insert(self, query):
              '''
              Takes in an insert SQL query and applies security policies related to
              the insert access type to it. Currently, we only support one type
              of insert permission -- which is that the user making the insert call
      Severity: Minor
      Found in src/core/db/query_rewriter.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method __init__. (11)
      Open

          def __init__(self, request):
              # First extract the easy variables.
              self.draw = int(request.GET["draw"])
              self.start = int(request.GET["start"])
              self.length = int(request.GET["length"])

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Function show has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          Step.prototype.show = function() {
            var _this = this;
            if (this.el == null) {
              this.render();
              if (this.options.style) {
      Severity: Minor
      Found in src/browser/static/dbwipes/js/lib/shepherd.js - About 1 hr to fix

        Function show has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            Step.prototype.show = function() {
              var _this = this;
              if (this.el == null) {
                this.render();
                if (this.options.style) {
        Severity: Minor
        Found in src/apps/dbwipes/static/js/lib/shepherd.js - About 1 hr to fix

          Function onSubmit has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              onSubmit: function() {
                var db = this.$('input[name=q-db]').val(),
                    table = this.$('input[name=q-table]').val(),
                    xexpr = this.$('input[name=q-x-expr]').val(),
                    xcol = this.$('input[name=q-x-col]').val(),
          Severity: Minor
          Found in src/apps/dbwipes/static/js/summary/queryform.js - About 1 hr to fix

            Function onSubmit has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                onSubmit: function() {
                  var db = this.$('input[name=q-db]').val(),
                      table = this.$('input[name=q-table]').val(),
                      xexpr = this.$('input[name=q-x-expr]').val(),
                      xcol = this.$('input[name=q-x-col]').val(),
            Severity: Minor
            Found in src/browser/static/dbwipes/js/summary/queryform.js - About 1 hr to fix

              Function display_query has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                var display_query = function() {
              
                  /**********************************/
                  /*** 1: Selected Tables/Columns ***/
                  /**********************************/
              Severity: Minor
              Found in src/apps/dataq/client_src/js/dataq.js - About 1 hr to fix

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

                },{"hbsfy/runtime":20}],8:[function(require,module,exports){
                // hbsfy compiled Handlebars template
                var HandlebarsCompiler = require('hbsfy/runtime');
                module.exports = HandlebarsCompiler.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
                    var helper, alias1=helpers.helperMissing, alias2="function", alias3=this.escapeExpression;
                Severity: Minor
                Found in src/browser/static/datatables/js/dataTables.extra.js - 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 apply_row_level_security_update has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def apply_row_level_security_update(self, query):
                        '''
                        Takes in an update SQL query and applies security policies related to
                        the update access type to it.
                        '''
                Severity: Minor
                Found in src/core/db/query_rewriter.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

                Severity
                Category
                Status
                Source
                Language