kuasha/cosmos

View on GitHub
cosmos/dataservice/objectservice.py

Summary

Maintainability
F
1 wk
Test Coverage

File objectservice.py has 361 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
 Copyright (C) 2014 Maruf Maniruzzaman
 Website: http://cosmosframework.com
 Author: Maruf Maniruzzaman
 License :: OSI Approved :: MIT License
Severity: Minor
Found in cosmos/dataservice/objectservice.py - About 4 hrs to fix

    ObjectService has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ObjectService():
        def __init__(self, *args, **kwargs):
            self.rbac_service = kwargs.get("rbac_service", RbacService())
            self.db = kwargs.get("db", None)
    
    
    Severity: Minor
    Found in cosmos/dataservice/objectservice.py - About 2 hrs to fix

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

          def check_access(self, user, object_name, properties, access, check_owner=False):
              roles = self.rbac_service.get_roles(user)
      
              # We must check all roles for possible access before checking owner access, so we need to loop twice.
              # Since owner access is suggested rare optimizing for role access here,
      Severity: Minor
      Found in cosmos/dataservice/objectservice.py - About 55 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

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

          def get_properties(self, data, namespace=None):
              properties = list(data.keys())
              child_props = []
      
              for prop in properties:
      Severity: Minor
      Found in cosmos/dataservice/objectservice.py - About 55 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

      Function save_file_in_gridfs has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def save_file_in_gridfs(db, user, collection_name, file_object, properties, file_id=None):
      Severity: Minor
      Found in cosmos/dataservice/objectservice.py - About 45 mins to fix

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

            def find(self, user, object_name, query, columns, limit=5000):
        Severity: Minor
        Found in cosmos/dataservice/objectservice.py - About 35 mins to fix

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

              def check_access(self, user, object_name, properties, access, check_owner=False):
          Severity: Minor
          Found in cosmos/dataservice/objectservice.py - About 35 mins to fix

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

                def text_search(self, user, object_name, query, columns, limit=5000):
            Severity: Minor
            Found in cosmos/dataservice/objectservice.py - About 35 mins to fix

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

              def read_gridfs_file(db, collection_name, file_id, properties, ignore_col_name=False):
              Severity: Minor
              Found in cosmos/dataservice/objectservice.py - About 35 mins to fix

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

                def read_gridfs_owned_file(user, db, collection_name, file_id, properties):
                Severity: Minor
                Found in cosmos/dataservice/objectservice.py - About 35 mins to fix

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

                      def add_operation_preprocessor(self, preprocessor, object_name, access_types):
                          assert isinstance(access_types, collections.Iterable)
                  
                          assert len(object_name) > 0
                  
                  
                  Severity: Minor
                  Found in cosmos/dataservice/objectservice.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 find has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def find(self, user, object_name, query, columns, limit=5000):
                          logging.debug("ObjectService::find::{0}".format(object_name))
                          #assert inspect.ismethod(callback)
                  
                          allowed_access_type = self.check_access(user, object_name, columns, AccessType.READ, True)
                  Severity: Minor
                  Found in cosmos/dataservice/objectservice.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 add_operation_postprocessor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def add_operation_postprocessor(self, postprocessor, object_name, access_types):
                          #assert inspect.ismethod(preprocessor)
                          assert isinstance(access_types, collections.Iterable)
                  
                          assert len(object_name) > 0
                  Severity: Minor
                  Found in cosmos/dataservice/objectservice.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 read_gridfs_owned_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def read_gridfs_owned_file(user, db, collection_name, file_id, properties):
                      owner_id = user.get("_id")
                  
                      if len(owner_id) < 1:
                          raise tornado.web.HTTPError(401, "Unauthorized")
                  Severity: Minor
                  Found in cosmos/dataservice/objectservice.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 read_gridfs_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def read_gridfs_file(db, collection_name, file_id, properties, ignore_col_name=False):
                      fs = motor.MotorGridFS(db)
                      try:
                          gridout = yield fs.get(ObjectId(file_id))
                  
                  
                  Severity: Minor
                  Found in cosmos/dataservice/objectservice.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 add_operation_processor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def add_operation_processor(self, processor, object_name, access_types):
                          assert isinstance(access_types, collections.Iterable)
                  
                          assert len(object_name) > 0
                  
                  
                  Severity: Minor
                  Found in cosmos/dataservice/objectservice.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 text_search has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def text_search(self, user, object_name, query, columns, limit=5000):
                          logging.debug("ObjectService::text_search::{0}".format(object_name))
                  
                          allowed_access_type = self.check_access(user, object_name, columns, AccessType.SEARCH, True)
                  
                  
                  Severity: Minor
                  Found in cosmos/dataservice/objectservice.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

                      def find(self, user, object_name, query, columns, limit=5000):
                          logging.debug("ObjectService::find::{0}".format(object_name))
                          #assert inspect.ismethod(callback)
                  
                          allowed_access_type = self.check_access(user, object_name, columns, AccessType.READ, True)
                  Severity: Major
                  Found in cosmos/dataservice/objectservice.py and 1 other location - About 1 day to fix
                  cosmos/dataservice/objectservice.py on lines 124..145

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

                  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 text_search(self, user, object_name, query, columns, limit=5000):
                          logging.debug("ObjectService::text_search::{0}".format(object_name))
                  
                          allowed_access_type = self.check_access(user, object_name, columns, AccessType.SEARCH, True)
                  
                  
                  Severity: Major
                  Found in cosmos/dataservice/objectservice.py and 1 other location - About 1 day to fix
                  cosmos/dataservice/objectservice.py on lines 100..122

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

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

                      def add_operation_processor(self, processor, object_name, access_types):
                          assert isinstance(access_types, collections.Iterable)
                  
                          assert len(object_name) > 0
                  
                  
                  Severity: Major
                  Found in cosmos/dataservice/objectservice.py and 2 other locations - About 1 day to fix
                  cosmos/dataservice/objectservice.py on lines 301..318
                  cosmos/dataservice/objectservice.py on lines 339..357

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

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

                      def add_operation_preprocessor(self, preprocessor, object_name, access_types):
                          assert isinstance(access_types, collections.Iterable)
                  
                          assert len(object_name) > 0
                  
                  
                  Severity: Major
                  Found in cosmos/dataservice/objectservice.py and 2 other locations - About 1 day to fix
                  cosmos/dataservice/objectservice.py on lines 320..337
                  cosmos/dataservice/objectservice.py on lines 339..357

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

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

                      def add_operation_postprocessor(self, postprocessor, object_name, access_types):
                          #assert inspect.ismethod(preprocessor)
                          assert isinstance(access_types, collections.Iterable)
                  
                          assert len(object_name) > 0
                  Severity: Major
                  Found in cosmos/dataservice/objectservice.py and 2 other locations - About 1 day to fix
                  cosmos/dataservice/objectservice.py on lines 301..318
                  cosmos/dataservice/objectservice.py on lines 320..337

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

                  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 prop in properties:
                              prop_data = data.get(prop, None)
                  
                              if prop_data and isinstance(prop_data, dict):
                                  child_namespace = (namespace + "." + prop) if namespace else prop
                  Severity: Major
                  Found in cosmos/dataservice/objectservice.py and 1 other location - About 3 hrs to fix
                  cosmos/service/requesthandler.py on lines 78..83

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

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

                      def get_operation_postprocessor(self, object_name, access_type):
                          assert len(object_name) > 0
                          object_postprocessor = self._postprocessors.get(object_name)
                  
                          if not object_postprocessor:
                  Severity: Major
                  Found in cosmos/dataservice/objectservice.py and 2 other locations - About 3 hrs to fix
                  cosmos/dataservice/objectservice.py on lines 359..370
                  cosmos/dataservice/objectservice.py on lines 372..383

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

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

                      def get_operation_processor(self, object_name, access_type):
                          assert len(object_name) > 0
                          object_processor = self._processors.get(object_name)
                  
                          if not object_processor:
                  Severity: Major
                  Found in cosmos/dataservice/objectservice.py and 2 other locations - About 3 hrs to fix
                  cosmos/dataservice/objectservice.py on lines 359..370
                  cosmos/dataservice/objectservice.py on lines 385..396

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

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

                      def get_operation_preprocessor(self, object_name, access_type):
                          assert len(object_name) > 0
                          object_preprocessor = self._preprocessors.get(object_name)
                  
                          if not object_preprocessor:
                  Severity: Major
                  Found in cosmos/dataservice/objectservice.py and 2 other locations - About 3 hrs to fix
                  cosmos/dataservice/objectservice.py on lines 372..383
                  cosmos/dataservice/objectservice.py on lines 385..396

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

                  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 role in roles:
                              has_access = self.rbac_service.has_access(role, object_name, properties, access)
                              if has_access:
                                  logging.debug("ObjectService:: check _access {0} is granted to {1} as role accessible for properties {2}.".format(object_name, user, properties))
                                  return ACCESS_TYPE_ROLE
                  Severity: Major
                  Found in cosmos/dataservice/objectservice.py and 1 other location - About 1 hr to fix
                  cosmos/dataservice/objectservice.py on lines 46..50

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

                  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 check_owner:
                                  has_owner_access = self.rbac_service.has_owner_access(role, object_name, properties, access)
                                  if has_owner_access:
                                      logging.debug("ObjectService:: check _access {0} is granted to {1} as owner accessible for properties {2}.".format(object_name, user, properties))
                                      return ACCESS_TYPE_OWNER_ONLY
                  Severity: Major
                  Found in cosmos/dataservice/objectservice.py and 1 other location - About 1 hr to fix
                  cosmos/dataservice/objectservice.py on lines 39..43

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

                  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 user:
                              data['owner'] = str(user.get("_id"))
                          else:
                              data['owner'] = SYSTEM_USER
                  Severity: Minor
                  Found in cosmos/dataservice/objectservice.py and 1 other location - About 55 mins to fix
                  cosmos/dataservice/objectservice.py on lines 66..69

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

                  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 user:
                              data['owner'] = str(user.get("_id"))
                          else:
                              data['owner'] = SYSTEM_USER
                  Severity: Minor
                  Found in cosmos/dataservice/objectservice.py and 1 other location - About 55 mins to fix
                  cosmos/dataservice/objectservice.py on lines 91..94

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

                  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

                          properties = [p if not namespace else namespace + "." + p for p in properties]
                  Severity: Minor
                  Found in cosmos/dataservice/objectservice.py and 1 other location - About 45 mins to fix
                  cosmos/service/requesthandler.py on lines 88..88

                  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

                  There are no issues that match your filters.

                  Category
                  Status