Skip to content

Commit 265b1b3

Browse files
authored
Enable autofixing for accessibility bugs (#2845)
1 parent 03c005e commit 265b1b3

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

bugbot/rules/accessibilitybug.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def __init__(self, confidence_threshold: float = 0.9):
1818
"""
1919
super().__init__()
2020
self.confidence_threshold = confidence_threshold
21+
self.autofix_access: list[int] = []
2122

2223
def description(self):
2324
return "[Using ML] Detected accessibility bugs"
@@ -71,11 +72,30 @@ def get_bugs(self, date="today", bug_ids=[]):
7172
"id": bug_id,
7273
"summary": bug["summary"],
7374
"confidence": nice_round(prob[1]),
74-
"autofixed": prob[1] >= self.confidence_threshold,
75+
"autofixed": False,
7576
}
7677

78+
# Only autofix results for which we are sure enough.
79+
if prob[1] >= self.confidence_threshold:
80+
results[bug_id]["autofixed"] = True
81+
self.autofix_access.append(bug_id)
82+
7783
return results
7884

85+
def get_autofix_change(self) -> dict:
86+
cc = self.get_config("cc")
87+
88+
return {
89+
bug_id: {
90+
"keywords": {"add": ["access"]},
91+
"cc": {"add": cc},
92+
"comment": {
93+
"body": "The [Bugbug](https://github.com/mozilla/bugbug/) bot thinks this bug is an accessibility bug, but please revert this change in case of error."
94+
},
95+
}
96+
for bug_id in self.autofix_access
97+
}
98+
7999

80100
if __name__ == "__main__":
81101
AccessibilityBug().run()

0 commit comments

Comments
 (0)