Completed
Pull Request — master (#2609)
by Udayan
02:12
created

ProjectWideBear.analyze()   A

Complexity

Conditions 1

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 12
loc 12
rs 9.4285
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 View Code Duplication
class ProjectWideBear(Bear):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
Unused Code introduced by
This abstract class does not seem to be used anywhere.
Loading history...
7
    """
8
    A ProjectWideBear is a Bear that analyzes all files at once. This has the
9
    advantage of drawing advanced semantic analysis that give results that are
10
    applicable to the whole codebase.
11
    """
12
13
    def __init__(self,
14
                 file_set,  # A set of file_proxies
15
                 section,
16
                 message_queue,
17
                 timeout=0):
18
        Bear.__init__(self, section, message_queue, timeout)
19
        self.file_set = file_set
20
21
        self.kwargs = self.get_metadata().create_params_from_section(section)
22
23
    @staticmethod
24
    def kind():
25
        return BEAR_KIND.PROJECTWIDE
26
27
    def execute_task(self, task, kwargs):
28
        """
29
        This method is responsible for getting results from the
30
        analysis routines.
31
        """
32
        return list(self.analyze(task, **kwargs))
33
34
    def analyze(self,
35
                file_set,
36
                *args,
37
                dependency_results=None,
38
                **kwargs):
39
        """
40
        Handles the given file.
41
42
        :param file_set:       A set of FileProxy objects.
43
        :return:               A list of Result
44
        """
45
        raise NotImplementedError("This function has to be implemented for a "
46
                                  "runnable bear.")
47
48
    def generate_tasks(self):
49
        """
50
        This method is responsible for providing the files and arguments for
51
        the tasks the bear needs to perform.
52
        """
53
        return [self.file_set, self.kwargs]
54
55
    @classmethod
56
    def get_metadata(cls):
57
        return FunctionMetadata.from_function(
58
            cls.run,
59
            omit={"self", "file_proxy", "dependency_results"})
0 ignored issues
show
Coding Style introduced by
Final newline missing
Loading history...