Total Complexity | 3 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from coalib.bears.Bear import Bear |
||
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 |