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

Substitution with "ignorecase: true" doesn't produce the expected result #873

Closed
1 task done
alexvonme opened this issue Jul 23, 2024 · 3 comments
Closed
1 task done

Comments

@alexvonme
Copy link

Check for existing issues

  • Completed

Environment

  1. Linux

    • VS Code Extension
    • Direct Download
    • Version: 3.7.0
  2. Vale Studio

    • Version: 3.6.1

Describe the bug / provide steps to reproduce it

I wanted to create a rule that corrects miswritten versions for the abbreviation of Mozilla Public License (MPL):

extends: substitution
ignorecase: true
level: warning
message: Use '%s' instead of '%s'
action:
  name: replace
swap:
  MPL: MPL
  MPL[ -]?2(?:\.0)?: MPL 2.0

However, the rule doesn't correct "mpl 2.0" regardless of any changes I've made to it. The results are:

Matched
mpl
mpl 2
mpl2.0
MPL2.0

Not Matched
mpl 2.0

Correct
MPL
MPL 2.0

In case a relatively complex rule doesn't handle ignorecase: true well, I also tried to write more explicit rules but I still couldn't reach and change "mpl 2.0". The rule performs well with the other examples, could it be that with ignorecase: true, complicated rule corrections are also taken with ignorecase?

Alternatively, is there a syntax issue in the rule that I'm missing?

@alexvonme alexvonme changed the title Substitution and "ignorecase: true" doesn't produce the expected result Substitution with "ignorecase: true" doesn't produce the expected result Jul 23, 2024
@alexvonme
Copy link
Author

My earlier description may not have been sufficiently descriptive. In an ignorecase:true substitution rule where there are the following swap operations:

MPL: MPL
MPL[ -]?2(?:\.0)?: MPL 2.0

All incorrect capitalization of MPL, such as mpl, Mpl or mpL are corrected to MPL.
However, incorrect capitalizations of MPL 2.0, such as mpl 2.0, Mpl 2.0 or mpL 2.0 are not corrected. This isn't explained by the regex search string in the left side not functioning with ignorecase since something like mpl 2 is still corrected.

Changing the rule so that it explicitly targets mpl 2.0, as shown below, still doesn't lead to Vale correcting it.

(?:mpl|MPL)[ -]?2(?:\.0)?: MPL 2.0

These lead me to conclude that in substitution rules that utilize ignorecase:true, with swap options that include special characters, the corrections also become case insensitive.

@jdkato
Copy link
Member

jdkato commented Aug 20, 2024

Thanks for the reports. This should be fixed in the next release.

jdkato added a commit that referenced this issue Aug 20, 2024
@ccoVeille
Copy link
Contributor

Thanks for the reports. This should be fixed in the next release.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants