Skip to content

Commit bd96608

Browse files
committed
Fix lint issues from revive
1 parent 6db670c commit bd96608

File tree

15 files changed

+68
-33
lines changed

15 files changed

+68
-33
lines changed

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ linters:
55
enable:
66
# https://github.com/go-critic/go-critic
77
- gocritic
8+
# https://github.com/mgechev/revive
9+
- revive
810
# https://github.com/mdempsky/unconvert
911
- unconvert
1012
# https://github.com/mvdan/unparam

cmd/namigo/main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package main is the entry point for the namigo CLI application.
12
package main
23

34
import (
@@ -16,15 +17,15 @@ var (
1617
)
1718

1819
// checkSizeFlag checks for valid size flag.
19-
func checkSizeFlag(ctx *cli.Context, i int) error {
20+
func checkSizeFlag(_ *cli.Context, i int) error {
2021
if i <= 0 {
2122
return fmt.Errorf("size %d is invalid", i)
2223
}
2324
return nil
2425
}
2526

2627
// checkLengthFlag checks for valid length flag.
27-
func checkLengthFlag(ctx *cli.Context, i int) error {
28+
func checkLengthFlag(_ *cli.Context, i int) error {
2829
if i <= 0 {
2930
return fmt.Errorf("length %d is invalid", i)
3031
}
@@ -114,7 +115,7 @@ func main() {
114115
{
115116
Name: "version",
116117
Usage: "Print version information",
117-
Action: func(ctx *cli.Context) error {
118+
Action: func(*cli.Context) error {
118119
fmt.Printf("namigo %s, commit %s, built at %s\n", version, commit, date)
119120
return nil
120121
},

cmd/namigo/sub/generate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func GeneratePromptAction(c *cli.Context) error {
3232
maxSize := c.Int("size")
3333
maxLength := c.Int("length")
3434

35-
prompt, err := generate.GeneratePrompt(purpose, theme, demographics, interests, maxSize, maxLength)
35+
prompt, err := generate.Prompt(purpose, theme, demographics, interests, maxSize, maxLength)
3636
if err != nil {
3737
return err
3838
}

cmd/namigo/sub/search.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/urfave/cli/v2"
1515
)
1616

17+
// ErrMissingSearchTerm is returned when the search term is missing.
1718
var ErrMissingSearchTerm = errors.New("missing search term")
1819

1920
// SearchPackageAction searches for packages.
@@ -27,7 +28,7 @@ func SearchPackageAction(c *cli.Context) error {
2728

2829
ptf := search.NewSearchPortfolio(outputFormat)
2930

30-
ptf.Register(func(sp *search.SearchPortfolio) (model.SearchResult, error) {
31+
ptf.Register(func() (model.SearchResult, error) {
3132
key := model.GoKey
3233
fmt.Printf("🔍 Search for %s results\n", key)
3334
values, err := golang.SearchByScrape(searchTerm, maxSize)
@@ -41,7 +42,7 @@ func SearchPackageAction(c *cli.Context) error {
4142
return model.SearchResult{Key: key, Records: records}, nil
4243
})
4344

44-
ptf.Register(func(sp *search.SearchPortfolio) (model.SearchResult, error) {
45+
ptf.Register(func() (model.SearchResult, error) {
4546
key := model.NPMKey
4647
fmt.Printf("🔍 Search for %s results\n", key)
4748
values, err := npm.SearchByAPI(searchTerm, maxSize)
@@ -55,7 +56,7 @@ func SearchPackageAction(c *cli.Context) error {
5556
return model.SearchResult{Key: key, Records: records}, nil
5657
})
5758

58-
ptf.Register(func(sp *search.SearchPortfolio) (model.SearchResult, error) {
59+
ptf.Register(func() (model.SearchResult, error) {
5960
key := model.PyPIKey
6061
fmt.Printf("🔍 Search for %s results\n", key)
6162
values, err := pypi.SearchByAPI(searchTerm, maxSize)
@@ -88,7 +89,7 @@ func SearchDNSAction(c *cli.Context) error {
8889

8990
ptf := search.NewSearchPortfolio(outputFormat)
9091

91-
ptf.Register(func(sp *search.SearchPortfolio) (model.SearchResult, error) {
92+
ptf.Register(func() (model.SearchResult, error) {
9293
key := model.DNSKey
9394
fmt.Printf("🔍 Search for %s results\n", key)
9495
values, err := dns.SearchByProbe(searchTerm, maxSize)
@@ -121,7 +122,7 @@ func SearchEmailAction(c *cli.Context) error {
121122

122123
ptf := search.NewSearchPortfolio(outputFormat)
123124

124-
ptf.Register(func(sp *search.SearchPortfolio) (model.SearchResult, error) {
125+
ptf.Register(func() (model.SearchResult, error) {
125126
key := model.EmailKey
126127
fmt.Printf("🔍 Search for %s results\n", key)
127128
values, err := email.SearchByProbe(searchTerm, maxSize)

internal/model/extern/extern.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package extern provides external models.
2+
package extern

internal/model/model.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package model provides the data models for the application.
2+
package model

internal/model/search.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,33 @@ package model
33
import "net"
44

55
const (
6-
NoAuthor = "No author" // Fallback for author
7-
NoDescription = "No description" // Fallback for description
6+
// NoAuthor is a fallback for author
7+
NoAuthor = "No author"
8+
9+
// NoDescription is a fallback for description
10+
NoDescription = "No description"
811
)
912

1013
// SearchKey is an enum for search keys
1114
type SearchKey int
1215

1316
const (
17+
// UnknownKey is a fallback for unknown search keys.
1418
UnknownKey SearchKey = iota
19+
20+
// GoKey is a key for Go packages.
1521
GoKey
22+
23+
// NPMKey is a key for NPM packages.
1624
NPMKey
25+
26+
// PyPIKey is a key for PyPI packages.
1727
PyPIKey
28+
29+
// DNSKey is a key for DNS records.
1830
DNSKey
31+
32+
// EmailKey is a key for email records.
1933
EmailKey
2034
)
2135

@@ -36,9 +50,10 @@ func (k SearchKey) String() string {
3650
}
3751
}
3852

39-
// SearchRecord is an union type for all search record values
53+
// SearchRecord is an union type for all search record values.
4054
type SearchRecord interface{ record() }
4155

56+
// GoPackage is a struct for Go package search results.
4257
type GoPackage struct {
4358
Name string // Package name
4459
Path string // Fully qualified package path
@@ -47,13 +62,15 @@ type GoPackage struct {
4762

4863
func (*GoPackage) record() {}
4964

65+
// NPMPackage is a struct for NPM package search results.
5066
type NPMPackage struct {
5167
Name string // Package name
5268
Description string // Package description
5369
}
5470

5571
func (*NPMPackage) record() {}
5672

73+
// PyPIPackage is a struct for PyPI package search results.
5774
type PyPIPackage struct {
5875
Name string // Package name
5976
Author string // Package author
@@ -62,13 +79,15 @@ type PyPIPackage struct {
6279

6380
func (*PyPIPackage) record() {}
6481

82+
// DNSRecord is a struct for DNS search results.
6583
type DNSRecord struct {
6684
FQDN string // Fully qualified domain name
6785
IPList []net.IP // Associated IP addresses
6886
}
6987

7088
func (*DNSRecord) record() {}
7189

90+
// EmailRecord is a struct for email search results.
7291
type EmailRecord struct {
7392
Addr string // Email address
7493
HasValidSyntax bool // Email address has valid syntax

internal/util/goquery.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func NewDocumentPipeline(
3232
}
3333
}
3434

35+
// Execute executes the pipeline and returns the document.
3536
func (dp *DocumentPipeline) Execute() (*goquery.Document, error) {
3637
req, err := dp.requestBuilder()
3738
if err != nil {

internal/util/util.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package util provides utility functions for the application.
12
package util
23

34
// dismiss ignores the error from a function/method

pkg/generate/generate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ type promptData struct {
2727
MaxLength int // Maximum length of each name
2828
}
2929

30-
// GeneratePrompt generates the prompt for AI chatbots.
31-
func GeneratePrompt(purpose, theme, demographics, interests string, size, length int) (string, error) {
30+
// Prompt generates the prompt for AI chatbots.
31+
func Prompt(purpose, theme, demographics, interests string, size, length int) (string, error) {
3232
if size < 0 || length < 0 {
3333
return "", ErrNegativeInput
3434
}

0 commit comments

Comments
 (0)