vincetse/python-s3-cache

View on GitHub

Showing 4 of 15 total issues

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

    def open(self, mode):
        """Opens a file to read or write operations."""
        self._bucket_exists_()
        s3cache.utils.makedirs(self.tmppath)
        self.mode = mode
Severity: Minor
Found in s3cache/s3file.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 testLocallyCached has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def testLocallyCached(self):
        s3 = self.bucketFactory()
        # Turn on caching
        s3.set_caching(True)
        object_name = "/foo/cached.txt"
Severity: Minor
Found in s3cache/tests/test_s3cache.py - About 1 hr to fix

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

        def __init__(self, tmpdir, bucket_name,
    Severity: Minor
    Found in s3cache/__init__.py - About 35 mins to fix

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

          def connect(self):
              """Connect to AWS S3.  """
              if self.conn is None:
                  try:
                      self.conn = boto.connect_s3(
      Severity: Minor
      Found in s3cache/__init__.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

      Severity
      Category
      Status
      Source
      Language