datahuborg/datahub

View on GitHub

Showing 1,132 of 1,132 total issues

Function apply_row_level_security_insert has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
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 - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

    def test_delete_view(self):
        con_delete_view = self.mock_connection.return_value.delete_view
        self.manager.delete_view(
            repo='repo_name', view='view_name', force=False)
        self.assertTrue(con_delete_view.called)
Severity: Major
Found in src/core/test/test_manager.py and 3 other locations - About 1 hr to fix
src/core/test/test_manager.py on lines 86..90
src/core/test/test_manager.py on lines 98..101
src/core/test/test_manager.py on lines 123..127

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

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

    def test_describe_view(self):
        con_describe_view = self.mock_connection.return_value.describe_view
        self.manager.describe_view(
            repo='repo_name', view='_name', detail=False)
        self.assertTrue(con_describe_view.called)
Severity: Major
Found in src/core/test/test_manager.py and 3 other locations - About 1 hr to fix
src/core/test/test_manager.py on lines 86..90
src/core/test/test_manager.py on lines 98..101
src/core/test/test_manager.py on lines 129..133

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

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

    def test_describe_table(self):
        con_describe_table = self.mock_connection.return_value.describe_table
        self.manager.describe_table(repo='repo', table='table', detail=False)

        self.assertTrue(con_describe_table.called)
Severity: Major
Found in src/core/test/test_manager.py and 3 other locations - About 1 hr to fix
src/core/test/test_manager.py on lines 98..101
src/core/test/test_manager.py on lines 123..127
src/core/test/test_manager.py on lines 129..133

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

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

    def test_delete_table(self):
        con_delete_table = self.mock_connection.return_value.delete_table
        self.manager.delete_table(repo='repo', table='table', force=False)
        self.assertTrue(con_delete_table.called)
Severity: Major
Found in src/core/test/test_manager.py and 3 other locations - About 1 hr to fix
src/core/test/test_manager.py on lines 86..90
src/core/test/test_manager.py on lines 123..127
src/core/test/test_manager.py on lines 129..133

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

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

        for code, exceptions in exceptions_by_status.iteritems():
            if next((code for e in exceptions
                    if issubclass(type(exception), e)), None):
                status_code = code
                break
Severity: Major
Found in src/browser/middleware.py and 1 other location - About 1 hr to fix
src/api/views.py on lines 953..956

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

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

    for drf_status, exceptions in exceptions_by_status.iteritems():
        if next((e for e in exceptions if issubclass(type(exc), e)), None):
            status_code = drf_status
            break
Severity: Major
Found in src/api/views.py and 1 other location - About 1 hr to fix
src/browser/middleware.py on lines 37..41

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

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

    _Tether.prototype.updateAttachClasses = function(elementAttach, targetAttach) {
      var add, all, side, sides, _i, _j, _len, _len1, _ref1,
        _this = this;
      if (elementAttach == null) {
        elementAttach = this.attachment;
Severity: Minor
Found in src/browser/static/dbwipes/js/lib/tether.js - About 1 hr to fix

    Function updateAttachClasses has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        _Tether.prototype.updateAttachClasses = function(elementAttach, targetAttach) {
          var add, all, side, sides, _i, _j, _len, _len1, _ref1,
            _this = this;
          if (elementAttach == null) {
            elementAttach = this.attachment;
    Severity: Minor
    Found in src/apps/dbwipes/static/js/lib/tether.js - About 1 hr to fix

      Function renderAxes has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          renderAxes: function(el) {
            if(el.select('.xaxis').size() == 0) {
              var xel = el.append('g')
                .attr('class', 'axis x xaxis')
                .attr('transform', "translate(0,"+this.state.h+")");
      Severity: Minor
      Found in src/browser/static/dbwipes/js/summary/queryview.js - About 1 hr to fix

        Function renderAxes has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            renderAxes: function(el) {
              if(el.select('.xaxis').size() == 0) {
                var xel = el.append('g')
                  .attr('class', 'axis x xaxis')
                  .attr('transform', "translate(0,"+this.state.h+")");
        Severity: Minor
        Found in src/apps/dbwipes/static/js/summary/queryview.js - About 1 hr to fix

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

                  if (request.method in permissions.SAFE_METHODS and
                      _card_is_public(repo_base=params['repo_base'],
                                      repo_name=params['repo_name'],
                                      card_name=params['card_name'])):
          Severity: Major
          Found in src/api/permissions.py and 1 other location - About 1 hr to fix
          src/api/permissions.py on lines 112..115

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                  if (request.method in permissions.SAFE_METHODS and
                      _card_is_public(repo_base=params['repo_base'],
                                      repo_name=params['repo_name'],
                                      card_name=params['card_name'])):
          Severity: Major
          Found in src/api/permissions.py and 1 other location - About 1 hr to fix
          src/api/permissions.py on lines 131..134

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 46.

          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 database_exists(self, db_name):
                  query = "SELECT 1 FROM pg_database WHERE datname=%s"
                  params = (db_name,)
                  result = self.execute_sql(query, params)
                  return (result['row_count'] > 0)
          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 587..591

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

          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 user_exists(self, username):
                  query = "SELECT 1 FROM pg_roles WHERE rolname=%s"
                  params = (username,)
                  result = self.execute_sql(query, params)
                  return (result['row_count'] > 0)
          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 593..597

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

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

              renderData: function(el, data, xalias, yalias) {
                var _this = this,
                    h = this.state.h,
                    w = this.state.w;
                var data = _.map(data, function(d) {
          Severity: Minor
          Found in src/browser/static/dbwipes/js/summary/queryview.js - About 1 hr to fix

            Function renderData has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                renderData: function(el, data, xalias, yalias) {
                  var _this = this,
                      h = this.state.h,
                      w = this.state.w;
                  var data = _.map(data, function(d) {
            Severity: Minor
            Found in src/apps/dbwipes/static/js/summary/queryview.js - About 1 hr to fix

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

              $(document).on("click", ".dt-delete-button", function() {
                // Delete the entire row.
                // button < span < div < th < tr
                $(this).parent().parent().parent().parent().remove();
              });
              Severity: Major
              Found in src/browser/static/datatables/js/dataTables.extra.js and 1 other location - About 1 hr to fix
              src/apps/datatables/client/js/filter-bar.js on lines 47..51

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

              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

              $(document).on("click", ".dt-delete-button", function() {
                // Delete the entire row.
                // button < span < div < th < tr
                $(this).parent().parent().parent().parent().remove();
              });
              Severity: Major
              Found in src/apps/datatables/client/js/filter-bar.js and 1 other location - About 1 hr to fix
              src/browser/static/datatables/js/dataTables.extra.js on lines 329..333

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

              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 index has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              def index(request, repo_base, repo, table):
                  """ Main page for dbWipes """
                  username = request.user.get_username()
                  cache_exists = does_cache_exist(repo_base)
              
              
              Severity: Minor
              Found in src/apps/dbwipes/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

              Severity
              Category
              Status
              Source
              Language