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

feature: Add bytes/strings NewReader support #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions MIRROR_FUNCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
<td><code>func bytes.NewBuffer(buf []byte *bytes.Buffer</code></td>
</tr>
<tr>
<td><code>func strings.NewReader(s string) *Reader</code></td>
<td><code>func bytes.NewReader(b []byte) *Reader</code></td>
</tr>
<tr>
<td><code>func (h *hash/maphash.Hash) WriteString(s string) (int, error)</code></td>
<td><code>func (h *hash/maphash.Hash) Write(b []byte) (int, error)</code></td>
</tr>
Expand Down
14 changes: 14 additions & 0 deletions checkers_bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ var (
Returns: 1,
},
},
{ // bytes.NewReader
Targets: checker.Bytes,
Type: checker.Function,
Package: "bytes",
Caller: "NewReader",
Args: []int{0},
AltPackage: "strings",
AltCaller: "NewReader",

Generate: &checker.Generate{
Pattern: `NewReader($0)`,
Returns: 1,
},
},
{ // bytes.Compare:
Targets: checker.Bytes,
Type: checker.Function,
Expand Down
14 changes: 14 additions & 0 deletions checkers_strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,20 @@ var (
Returns: 1,
},
},
{ // strings.NewReader
Targets: checker.Strings,
Type: checker.Function,
Package: "strings",
Caller: "NewReader",
Args: []int{0},
AltPackage: "bytes",
AltCaller: "NewReader",

Generate: &checker.Generate{
Pattern: `NewReader($0)`,
Returns: 1,
},
},
}

StringsBuilderMethods = []checker.Violation{
Expand Down
30 changes: 30 additions & 0 deletions testdata/bytes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions testdata/strings.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.