comp523/ITVS

View on GitHub

Showing 23 of 23 total issues

Function expression_to_tree has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

def expression_to_tree(expression):
    """
    A recursive decent parser using the shunting-yard algorithm to convert
    a well-formed expression string into an abstract syntax tree. The root
    node of this tree is returned.
Severity: Minor
Found in ranalyze/search.py - About 7 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Function searchController has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    var searchController = function($scope, database) {

        var self = this;

        $scope.form = {
Severity: Major
Found in ranalyze/static/js/controllers/searchController.js - About 3 hrs to fix

    Function databaseService has 74 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var databaseService = function($http, $httpParamSerializer, $q) {
    
            var self = this;
    
            self.entry = new (function(){
    Severity: Major
    Found in ranalyze/static/js/services/databaseService.js - About 2 hrs to fix

      Function search has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      def search(keywords=None, expression=None,
                 subreddit=None, after=None, before=None,
                 limit=None, offset=None, order=None,
                 include_count=False):
          """
      Severity: Minor
      Found in ranalyze/search.py - About 2 hrs to fix

      Cognitive Complexity

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

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

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

      Further reading

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

              for key, entry in data_copy.items():
                  db_entry = database.get_entry(key)
                  for fieldname, field in entry.items():
                      self.assertEqual(field, db_entry[fieldname])
      Severity: Major
      Found in ranalyze/ranalyze_test.py and 1 other location - About 2 hrs to fix
      ranalyze/ranalyze_test.py on lines 183..186

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

      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

              for key, entry in data_copy.items():
                  db_entry = database.get_entry(key)
                  for fieldname, field in entry.items():
                      self.assertEqual(field, db_entry[fieldname])
      Severity: Major
      Found in ranalyze/ranalyze_test.py and 1 other location - About 2 hrs to fix
      ranalyze/ranalyze_test.py on lines 197..200

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

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

          var cloudController = function($scope, $rootScope, database, tabs) {
      
              var self = this;
      
              $scope.cloudParams = {};
      Severity: Minor
      Found in ranalyze/static/js/controllers/cloudController.js - About 1 hr to fix

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

                self.search = function(download){
                    download = !!download;
                    var localParams = {
                        download: !!download
                    };
        Severity: Minor
        Found in ranalyze/static/js/controllers/searchController.js - About 1 hr to fix

          Function __init__ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, *args):
                  self.sql = ""
                  nargs = len(args)
                  if nargs > 0:
                      column = args[0]
          Severity: Minor
          Found in ranalyze/query.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 entry_search has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def entry_search():
              """
              Search wtihout expressions
              on GET: return csv of most recent simple search
              on POST: return JSON of search
          Severity: Minor
          Found in ranalyze/api.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 test_db has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def test_db(self):
          
                  print("Testing Database interface")
          
                  db_file = "testing.db"
          Severity: Minor
          Found in ranalyze/ranalyze_test.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 entry has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  self.entry = new (function(){
          
                      this.import = function(fileInputElement) {
          
                          var data = new FormData();
          Severity: Minor
          Found in ranalyze/static/js/services/databaseService.js - About 1 hr to fix

            Function search has 9 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def search(keywords=None, expression=None,
            Severity: Major
            Found in ranalyze/search.py - About 1 hr to fix

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

              def digest_entry(entry):
              
                  connect()
              
                  if not object_exists(entry, ENTRY_TABLE):
              Severity: Minor
              Found in ranalyze/frequency.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 __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, table, columns="*", where=None, distinct=False,
              Severity: Major
              Found in ranalyze/query.py - About 1 hr to fix

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

                def fetch_data(subreddit_set):
                    """
                    Fetch all posts and associated comments from a given subreddit set, after
                    the given entry id. Yields both Post and Comment instances.
                    """
                Severity: Minor
                Found in ranalyze/scrape.py - About 45 mins to fix

                Cognitive Complexity

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

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

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

                Further reading

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

                    def test_fetch_data(self):
                        """
                        Tests the ranalyze.fetch_data() function against a private
                        subreddit (r/itvs_testing) with known content
                        """
                Severity: Minor
                Found in ranalyze/ranalyze_test.py - About 45 mins to fix

                Cognitive Complexity

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

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

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

                Further reading

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

                def overview(gran, limit, day=None, month=None, year=None):
                Severity: Minor
                Found in ranalyze/frequency.py - About 35 mins to fix

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

                  def tree_to_condition(node):
                      """
                      Recursively convert an ASTNode to a Condition
                      """
                  
                  
                  Severity: Minor
                  Found in ranalyze/search.py - About 35 mins to fix

                  Cognitive Complexity

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

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

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

                  Further reading

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

                  def overview(gran, limit, day=None, month=None, year=None):
                      connect()
                      column_map = {
                          "year": year,
                          "month": month,
                  Severity: Minor
                  Found in ranalyze/frequency.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

                  Severity
                  Category
                  Status
                  Source
                  Language