Skip to content

Commit

Permalink
Fix pragmas that contain # (#14)
Browse files Browse the repository at this point in the history
* Fix pragmas that contain `#`

Signed-off-by: Akshit Garg <[email protected]>

* Bump version

Signed-off-by: Akshit Garg <[email protected]>

Signed-off-by: Akshit Garg <[email protected]>
  • Loading branch information
akshit-deepsource authored Jan 23, 2023
1 parent a03d42a commit bd39749
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/scatr/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/spf13/cobra"
)

const version = "0.3.0"
const version = "0.3.1"

var versionCmd = &cobra.Command{
Use: "version",
Expand Down
2 changes: 1 addition & 1 deletion pragma/pragma.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (p *Pragma) merge(other *Pragma) {
}

var (
pragmaRegex = regexp.MustCompile(`\s*\[([\w-]+)](:\s*([^#]+))?`)
pragmaRegex = regexp.MustCompile(`\s*\[([\w-]+)](:\s*(.*))?`)
issueRegex = regexp2.MustCompile(`\s*(\d+)?\s*("(.*?(?<!\\))")?`, regexp2.None)
)

Expand Down
10 changes: 10 additions & 0 deletions pragma/pragma_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ func TestParsePragma(t *testing.T) {
Hit: map[string]bool{"GO-W1000": false, "GO-W1001": false},
},
},
{
name: "rust pragma with #[must_use]",
args: args{comment: "[RS-E1017]: \"Calling `.hash(_)` on expression with unit-type `#[must_use]`\""},
want: &Pragma{
Issues: map[string][]*Issue{
"RS-E1017": {{Message: "Calling `.hash(_)` on expression with unit-type `#[must_use]`"}},
},
Hit: map[string]bool{"RS-E1017": false},
},
},
}

for _, tt := range tests {
Expand Down

0 comments on commit bd39749

Please sign in to comment.