LocalBear   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 14 1
A kind() 0 3 1
A get_metadata() 0 5 1
1
from coalib.bears.Bear import Bear
2
from coalib.bears.BEAR_KIND import BEAR_KIND
3
from coalib.settings.FunctionMetadata import FunctionMetadata
4
5
6
class LocalBear(Bear):
7
    """
8
    A LocalBear is a Bear that analyzes only one file at once. It therefore can
9
    not analyze semantical facts over multiple files.
10
11
    This has the advantage that it can be highly parallelized. In addition,
12
    the results from multiple bears for one file can be shown together for that
13
    file, which is better to grasp for the user. coala takes care of all that.
14
15
    Examples for LocalBear's could be:
16
17
    -   A SpaceConsistencyBear that checks every line for trailing whitespaces,
18
        tabs, etc.
19
    -   A VariableNameBear that checks variable names and constant names for
20
        certain conditions
21
    """
22
23
    @staticmethod
24
    def kind():
25
        return BEAR_KIND.LOCAL
26
27
    def run(self,
28
            filename,
29
            file,
30
            *args,
31
            dependency_results=None,
32
            **kwargs):
33
        """
34
        Handles the given file.
35
36
        :param filename: The filename of the file
37
        :param file:     The file contents as string array
38
        :return:         A list of Result
39
        """
40
        raise NotImplementedError("This function has to be implemented for a "
41
                                  "runnable bear.")
42
43
    @classmethod
44
    def get_metadata(cls):
45
        return FunctionMetadata.from_function(
46
            cls.run,
47
            omit={"self", "filename", "file", "dependency_results"})
48