• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / relman-auto-nag / #4403

pending completion
#4403

push

coveralls-python

suhaibmujahid
Replace the word "tool" with "rule"

639 of 3205 branches covered (19.94%)

57 of 57 new or added lines in 6 files covered. (100.0%)

1816 of 8004 relevant lines covered (22.69%)

0.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/bugbot/rules/multifix_regression.py
1
# This Source Code Form is subject to the terms of the Mozilla Public
2
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
# You can obtain one at http://mozilla.org/MPL/2.0/.
4

5
from collections import defaultdict
×
6

7
from bugbot.multi_autofixers import MultiAutoFixers, RulesChanges, UnexpectedRulesError
×
8
from bugbot.rules.needinfo_regression_author import NeedinfoRegressionAuthor
×
9
from bugbot.rules.regression_but_type_enhancement_task import (
×
10
    RegressionButEnhancementTask,
11
)
12
from bugbot.rules.regression_set_status_flags import RegressionSetStatusFlags
×
13

14

15
class MultiFixRegressed(MultiAutoFixers):
×
16
    """Merge changes from regression related rules and apply them to Bugzilla at once"""
17

18
    def __init__(self):
×
19
        super().__init__(
×
20
            RegressionButEnhancementTask(),
21
            RegressionSetStatusFlags(),
22
            NeedinfoRegressionAuthor(),
23
            comment=self.__merge_comment,
24
            keywords=self.__merge_keywords,
25
        )
26

27
    @staticmethod
×
28
    def __merge_comment(rules: RulesChanges) -> dict:
×
29
        rules_to_merge = rules.keys() - {
×
30
            RegressionButEnhancementTask,  # we can ignore the comment from this rule
31
        }
32

33
        if len(rules_to_merge) == 1:
×
34
            return rules[next(iter(rules_to_merge))]["comment"]
×
35

36
        if rules_to_merge == {
×
37
            RegressionSetStatusFlags,
38
            NeedinfoRegressionAuthor,
39
        }:
40
            return {
×
41
                "body": "\n\n".join(
42
                    [
43
                        rules[RegressionSetStatusFlags]["comment"]["body"],
44
                        rules[NeedinfoRegressionAuthor]["comment"]["body"],
45
                    ]
46
                ),
47
            }
48

49
        raise UnexpectedRulesError(rules_to_merge)
×
50

51
    @staticmethod
×
52
    def __merge_keywords(rules: RulesChanges) -> dict:
×
53
        merged_changes = defaultdict(set)
×
54
        for changes in rules.values():
×
55
            if "keywords" not in changes:
×
56
                continue
×
57

58
            for action, value in changes["keywords"].items():
×
59
                if isinstance(value, str):
×
60
                    value = [value]
×
61

62
                merged_changes[action].update(value)
×
63

64
        return {action: list(values) for action, values in merged_changes.items()}
×
65

66

67
if __name__ == "__main__":
×
68
    MultiFixRegressed().run()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc