Skip to content

Commit

Permalink
Merge pull request #23 from deepsourcelabs/fix-issue-collapse
Browse files Browse the repository at this point in the history
Fix an issue with multi-line pragma comments
  • Loading branch information
deepak-deepsource authored Mar 15, 2023
2 parents 9288247 + da1cfc5 commit d0a9e9f
Show file tree
Hide file tree
Showing 3 changed files with 28 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.4.2"
const version = "0.4.3"

var versionCmd = &cobra.Command{
Use: "version",
Expand Down
2 changes: 1 addition & 1 deletion pragma/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ func (f *File) extractPragmas() {
break
}

previousLine = line
line = strings.TrimSpace(line)
previousLine = line

var pragma *Pragma
lineNum := currentLineNum
Expand Down
26 changes: 26 additions & 0 deletions pragma/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,32 @@ print("Hello World")
},
},
},
{
name: "multi line pragma",
args: args{
content: `
class C2 : public B {
public:
// [CXX-W2008]: 34 "Grand-parent method"
// [CXX-W2008]: 49 "Grand-parent method"
int virt_1() override { return A1::virt_1() + A2::virt_1() + A3::virt_1(); }
// CHECK-FIXES: int virt_1() override { return B::virt_1() + B::virt_1() + B::virt_1(); }
};
`,
commentPrefix: []string{"//"},
},
want: map[int]*Pragma{
6: {
Issues: map[string][]*Issue{
"CXX-W2008": {
{Column: 49, Message: "Grand-parent method"},
{Column: 34, Message: "Grand-parent method"},
},
},
Hit: map[string]bool{"CXX-W2008": false},
},
},
},
{
name: "pragmas split on multiple lines",
args: args{
Expand Down

0 comments on commit d0a9e9f

Please sign in to comment.