Skip to content
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

Backend: Add regex test detekt rule #2931

Merged
merged 10 commits into from
Nov 16, 2024

Conversation

CalMWolfs
Copy link
Collaborator

@CalMWolfs CalMWolfs commented Nov 15, 2024

What

Added a detekt rule to enforce repo patterns to be accompanied by at least one regex test.

This makes sure that each repo pattern has a regex test unless it is a plain string.
Every regex test that accompanies a repo pattern must pass,
Every regex fail test that accompanies a repo pattern must fail

For now all repo patterns that are missing a regex test are baselined, but this means that when they are updated they will require a pattern. I will also try to add some regex tests to a lot of them.

This detekt rule also has possibilities for the future e.g.

  • Enforce naming conventions for the repo pattern variable as rn ~95% of them end in "Pattern"
  • Disallow unnamed capture groups, stuff like (.*) shouldn't be allowed
  • Making max line length pr ignore repo patterns so we dont need to supress it everywhere

Changelog Technical Details

  • Added a Detekt rule to enforce repo patterns to be accompanied by at least one regex test. - CalMWolfs

@CalMWolfs CalMWolfs added the Soon This Pull Request will be merged within the next couple of betas label Nov 15, 2024
@CalMWolfs CalMWolfs added this to the Version 0.28 milestone Nov 15, 2024
@github-actions github-actions bot added Backend A backend pull request that will be merged soon Detekt Has detekt problem labels Nov 15, 2024
Copy link

One or more Detekt Failures were detected:

@CalMWolfs CalMWolfs changed the title Backend: Add REGEX-FAIL and fix some regex and tests Backend: Add regex test detekt rule Nov 15, 2024
@NopoTheGamer
Copy link
Contributor

lgtm to me

Copy link

One or more Detekt Failures were detected:

  • BitsAPI.kt#L101: Repo pattern 'cookieDurationPattern' failed regex test: ' §7Duraaaaation: §a140d 8h 35m 36s' pattern: '\s*§7Duration: §a(?.*)'.

@github-actions github-actions bot removed the Detekt Has detekt problem label Nov 15, 2024
@CalMWolfs CalMWolfs enabled auto-merge (squash) November 16, 2024 06:52
@CalMWolfs CalMWolfs merged commit e57152f into hannibal002:beta Nov 16, 2024
6 checks passed
@github-actions github-actions bot removed Soon This Pull Request will be merged within the next couple of betas Backend A backend pull request that will be merged soon labels Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants