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

mozilla / relman-auto-nag / #5179

26 Jul 2024 03:57PM CUT coverage: 21.607% (-0.09%) from 21.692%
#5179

push

coveralls-python

benjaminmah
Separated `no_severity` rule into two separate rules

585 of 3505 branches covered (16.69%)

0 of 108 new or added lines in 3 files covered. (0.0%)

1 existing line in 1 file now uncovered.

1933 of 8946 relevant lines covered (21.61%)

0.22 hits per line

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

0.0
/bugbot/rules/workflow/no_severity_ni.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

NEW
5
from datetime import datetime
×
6

NEW
7
import numpy
×
NEW
8
from libmozdata import utils as lmdutils
×
9

NEW
10
from bugbot import utils
×
NEW
11
from bugbot.bzcleaner import BzCleaner
×
NEW
12
from bugbot.round_robin import RoundRobin
×
13

14

NEW
15
class NoSeverityNeedInfo(BzCleaner):
×
NEW
16
    def __init__(self, inactivity_days: int = 4):
×
17
        """Constructor
18

19
        Args:
20
            inactivity_days: number of days that a bug should be inactive before
21
                being considered.
22
        """
NEW
23
        super(NoSeverityNeedInfo, self).__init__()
×
NEW
24
        self.lookup_first = utils.get_config(self.name(), "weeks_lookup", 2)
×
NEW
25
        self.round_robin = RoundRobin.get_instance()
×
NEW
26
        self.components_skiplist = utils.get_config("workflow", "components_skiplist")
×
NEW
27
        self.activity_date = str(
×
28
            numpy.busday_offset(lmdutils.get_date("today"), -inactivity_days)
29
        )
30

NEW
31
    def description(self):
×
NEW
32
        return "Bugs without a severity or statuses set"
×
33

NEW
34
    def has_product_component(self):
×
NEW
35
        return True
×
36

NEW
37
    def ignore_meta(self):
×
NEW
38
        return True
×
39

NEW
40
    def columns(self):
×
NEW
41
        return ["product", "component", "id", "summary"]
×
42

NEW
43
    def handle_bug(self, bug, data):
×
NEW
44
        if (
×
45
            # Check if the product::component is in the list
46
            utils.check_product_component(self.components_skiplist, bug)
47
            or utils.get_last_no_bot_comment_date(bug) > self.activity_date
48
        ):
NEW
49
            return None
×
NEW
50
        return bug
×
51

NEW
52
    def get_mail_to_auto_ni(self, bug):
×
NEW
53
        string_to_search = "The severity field is not set for this bug."
×
54

NEW
55
        for comment in bug.get("comments", []):
×
NEW
56
            if string_to_search in comment.get("raw_text", ""):
×
NEW
57
                return None
×
58

NEW
59
        mail, nick = self.round_robin.get(bug, self.date)
×
NEW
60
        if mail and nick:
×
NEW
61
            return {"mail": mail, "nickname": nick}
×
NEW
62
        return None
×
63

NEW
64
    def get_bz_params(self, date):
×
NEW
65
        fields = [
×
66
            "triage_owner",
67
            "flags",
68
            "comments.creator",
69
            "comments.creation_time",
70
            "comments.raw_text",
71
        ]
NEW
72
        params = {
×
73
            "include_fields": fields,
74
            "keywords": "intermittent-failure",
75
            "keywords_type": "nowords",
76
            "email2": "wptsync@mozilla.bugs",
77
            "emailreporter2": "1",
78
            "emailtype2": "notequals",
79
            "resolution": "---",
80
            "f31": "bug_type",
81
            "o31": "equals",
82
            "v31": "defect",
83
            "f32": "flagtypes.name",
84
            "o32": "notsubstring",
85
            "v32": "needinfo?",
86
            "f33": "bug_severity",
87
            "o33": "anyexact",
88
            "v33": "--, n/a",
89
        }
NEW
90
        self.date = lmdutils.get_date_ymd(date)
×
NEW
91
        first = f"-{self.lookup_first * 7}d"
×
NEW
92
        params.update(
×
93
            {
94
                "f2": "flagtypes.name",
95
                "o2": "notequals",
96
                "v2": "needinfo?",
97
                "j3": "OR",
98
                "f3": "OP",
99
                "j4": "AND",
100
                "f4": "OP",
101
                "n5": 1,  # Ensure no change after the first period
102
                "f5": "product",
103
                "o5": "changedafter",
104
                "v5": first,
105
                "f6": "product",  # The bug has changed
106
                "o6": "changedafter",
107
                "v6": self.lookup_first * 7,
108
                "n7": 1,
109
                "f7": "component",
110
                "o7": "changedafter",
111
                "v7": first,
112
                "f8": "CP",
113
                "j9": "AND",
114
                "f9": "OP",
115
                "n10": 1,
116
                "f10": "component",
117
                "o10": "changedafter",
118
                "v10": first,
119
                "f11": "component",
120
                "o11": "changedafter",
121
                "v11": self.lookup_first * 7,
122
                "n12": 1,
123
                "f12": "product",
124
                "o12": "changedafter",
125
                "v12": first,
126
                "f13": "CP",
127
                "j14": "AND",
128
                "f14": "OP",
129
                "f15": "creation_ts",
130
                "o15": "lessthaneq",
131
                "v15": first,
132
                "f16": "creation_ts",
133
                "o16": "greaterthan",
134
                "v16": self.lookup_first * 7,
135
                "n17": 1,
136
                "f17": "product",
137
                "o17": "everchanged",
138
                "n18": 1,
139
                "f18": "component",
140
                "o18": "everchanged",
141
                "f19": "CP",
142
                "j20": "OR",
143
                "f20": "OP",
144
                "f21": "bug_severity",
145
                "o21": "changedfrom",
146
                "v21": "critical",
147
                "f22": "bug_severity",
148
                "o22": "changedfrom",
149
                "v22": "major",
150
                "f23": "bug_severity",
151
                "o23": "changedfrom",
152
                "v23": "blocker",
153
                "f24": "CP",
154
                "f30": "CP",
155
            }
156
        )
157

158
        # TODO: the following code can be removed in 2024.
159
        # https://github.com/mozilla/bugbot/issues/1596
160
        # Almost 500 old bugs have no severity set. The intent of the following
161
        # is to have them triaged in batches where every week we include more
162
        # bugs. Once the list of old bugs are reduced, we could safely remove
163
        # the following code.
NEW
164
        passed_time = datetime.now() - datetime.fromisoformat("2023-06-09")
×
NEW
165
        oldest_bug_months = 56 + passed_time.days
×
NEW
166
        n = utils.get_last_field_num(params)
×
NEW
167
        params.update(
×
168
            {
169
                f"f{n}": "creation_ts",
170
                f"o{n}": "greaterthan",
171
                f"v{n}": f"-{oldest_bug_months}m",
172
            }
173
        )
174

NEW
175
        return params
×
176

177

NEW
178
if __name__ == "__main__":
×
NEW
179
    NoSeverityNeedInfo().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