GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

b2blaze.models.bucket   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Test Coverage

Coverage 85.29%

Importance

Changes 0
Metric Value
eloc 38
dl 0
loc 75
ccs 29
cts 34
cp 0.8529
rs 10
c 0
b 0
f 0
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A B2Bucket.files() 0 4 1
A B2Bucket.edit() 0 3 1
A B2Bucket.delete() 0 27 4
A B2Bucket.__init__() 0 26 1
1
"""
2
Copyright George Sibble 2018
3
"""
4 1
from .file_list import B2FileList
5 1
from ..b2_exceptions import B2Exception
6 1
from ..api import API
7
8 1
class B2Bucket(object):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
best-practice introduced by
Too many instance attributes (10/7)
Loading history...
9
    """
10
11
    """
12 1
    def __init__(self, connector, parent_list, bucketId, bucketName, bucketType, bucketInfo, lifecycleRules, revision,
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (118/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
best-practice introduced by
Too many arguments (10/5)
Loading history...
Unused Code introduced by
The argument args seems to be unused.
Loading history...
Unused Code introduced by
The argument kwargs seems to be unused.
Loading history...
13
                 corsRules, *args, **kwargs):
14
        """
15
16
        :param connector:
17
        :param parent_list:
18
        :param bucketId:
19
        :param bucketName:
20
        :param bucketType:
21
        :param bucketInfo:
22
        :param lifecycleRules:
23
        :param revision:
24
        :param corsRules:
25
        :param args:
26
        :param kwargs:
27
        """
28 1
        self.bucket_id = bucketId
29 1
        self.bucket_name = bucketName
30 1
        self.bucket_type = bucketType
31 1
        self.bucket_info = bucketInfo
32 1
        self.lifecycle_rules = lifecycleRules
33 1
        self.revision = revision
34 1
        self.cors_rules = corsRules
35 1
        self.connector = connector
36 1
        self.parent_list = parent_list
37 1
        self.deleted = False
38
39 1
    def delete(self, delete_files=False, confirm_non_empty=False):
40
        """ Delete a bucket.
41
42
        Params:
43
            delete_files:           (bool)  Delete all files first.
44
            confirm_non_empty:      (bool)  Confirm deleting on bucket not empty.
45
        """
46 1
        path = API.delete_bucket
47 1
        files = self.files.all(include_hidden=True)
0 ignored issues
show
Unused Code introduced by
The variable files seems to be unused.
Loading history...
48 1
        if delete_files:
49
            if not confirm_non_empty:
50
                raise B2Exception('Bucket is not empty! Must confirm deletion of all files with confirm_non_empty=True')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (120/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
51
            else:
52
                print("Deleting all files from bucket. Beware API limits!")
0 ignored issues
show
Unused Code Coding Style introduced by
There is an unnecessary parenthesis after print.
Loading history...
53
                self.files.delete_all(confirm=True)
54
            
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
55
56 1
        params = {
57
            'bucketId': self.bucket_id
58
        }
59 1
        response = self.connector.make_request(path=path, method='post', params=params, account_id_required=True)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (113/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
60 1
        if response.status_code == 200:
61 1
            self.deleted = True
62 1
            del self.parent_list._buckets_by_name[self.bucket_name]
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _buckets_by_name was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
63 1
            del self.parent_list._buckets_by_id[self.bucket_id]
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _buckets_by_id was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
64
        else:
65 1
            raise B2Exception.parse(response)
66
67 1
    def edit(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
68
        #TODO:  Edit details
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
69
        pass
70
71 1
    @property
72
    def files(self):
73
        """ List of files in the bucket. B2FileList instance. """
74
        return B2FileList(connector=self.connector, bucket=self)
0 ignored issues
show
Coding Style introduced by
Final newline missing
Loading history...