Skip to content

ERA001: Allow Jira and gitlab references #17501

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

maldoinc
Copy link

@maldoinc maldoinc commented Apr 20, 2025

Summary

This extends the ERA001 check to allow references to Jira issues and GitLab merge requests. Currently, only GitHub-style issue references are excluded from being flagged as commented-out code.

Previously, lines like the following were incorrectly flagged:

Jira issue reference

See: PROJ-1234

GitLab MR reference

See: !15

These are now correctly treated as comments, not code.

Test Plan

Added unit tests to verify the behavior.

@ntBre
Copy link
Contributor

ntBre commented Apr 21, 2025

Thanks for working on this!

Does this correspond to an open issue? It's usually nice to discuss these things a bit before jumping into the implementation.

I can reproduce the Jira issue if there's a colon after See, but not otherwise: https://play.ruff.rs/cf52731c-e71a-4f6b-b736-1049d04b5133

so it's not really clear to me how big of an issue this is. There are several other heuristics used for determining code, not just the HASH_NUMBER regex, and in combination they seem to handle most of these cases.

If we decide we need to do something here still, another option is a user-configurable list of regular expressions. It sounds like that's what the upstream linter does, although I'm not sure if we have any other config options with user-facing regexes. cc @MichaReiser

@MichaReiser MichaReiser added the rule Implementing or modifying a lint rule label Apr 22, 2025
@maldoinc
Copy link
Author

There wasn't any discussion, more of a "scratch your own itch" situation. I used Ruff + Jira and this resulted in some positives. Since the github format was in, I figured why not extend it to jira. As you noted it is the : that makes the difference or not.

@MichaReiser
Copy link
Member

MichaReiser commented Apr 23, 2025

IMO, it makes sense to have the rule being consistent with what we have for TD003. I'm a bit surprised to see that TD003 neither supports GitLab or JIRA comments, it seems.

static ISSUE_LINK_TODO_LINE_REGEX_SET: LazyLock<RegexSet> = LazyLock::new(|| {
RegexSet::new([
r"\s*(http|https)://.*", // issue link
r"\s*#\d+.*", // issue code - like "#003"
])
.unwrap()
});

But I'm okay allowlisting JIRA here, specifically # See: PROJ-999 but I'm leaning towards adding the regex to the existing ALLOWLIST regex group

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants