Skip to content

Commit

Permalink
Fix validation of group name (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
josefpihrt authored Jul 28, 2023
1 parent c2b259c commit 236e13b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.4.0-beta2] - 2023-07-29

### Added

- Fix validation of group name ([#58](https://github.com/josefpihrt/roslynator/pull/58)).

## [0.4.0-beta] - 2023-07-28

### Added

- Add [.NET API](https://josefpihrt.github.io/docs/orang/ref) ([#51](https://github.com/josefpihrt/roslynator/pull/51)).
Expand Down
8 changes: 3 additions & 5 deletions src/CommandLine/ParseContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1576,12 +1576,10 @@ public bool TryParseFilter(
return false;
}

int groupIndex = -1;

if (groupName is not null)
{
groupIndex = regex.GroupNumberFromName(groupName);
if (groupIndex == -1)
int groupNumber = regex.GroupNumberFromName(groupName);
if (groupNumber == -1)
{
string message = $"Group '{groupName}' does not exist.";

Expand All @@ -1601,7 +1599,7 @@ public bool TryParseFilter(
matcher = new Matcher(
regex,
invert: (patternOptions & PatternOptions.Negative) != 0,
group: groupIndex,
group: groupName,
predicate: predicate);

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/FileSystem.ApiTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void Main()

IOperationResult result = new SearchBuilder()
.MatchDirectory(d => d
.Name(Pattern.Any("bin", "obj", PatternOptions.Equals | PatternOptions.WholeWord | PatternOptions.WholeLine))
.Name(Pattern.Any("bin", "obj", PatternOptions.Equals))
.NonEmpty())
.SkipDirectory(Pattern.Any(".git", ".vs", PatternOptions.Equals | PatternOptions.Literal))
.Delete(d => d
Expand Down

0 comments on commit 236e13b

Please sign in to comment.