Skip to content

Commit 147945b

Browse files
authored
Merge pull request #71 from hhatto/fix-lint-warnings
Fix lint warnings
2 parents 80d89c9 + d4bce40 commit 147945b

5 files changed

Lines changed: 18 additions & 18 deletions

File tree

cmd/gocloc/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"strings"
99

1010
"github.com/hhatto/gocloc"
11-
flags "github.com/jessevdk/go-flags"
11+
"github.com/jessevdk/go-flags"
1212
)
1313

1414
// Version is version string for gocloc command
@@ -41,7 +41,7 @@ var rowLen = 79
4141
// CmdOptions is gocloc command options.
4242
// It is necessary to use notation that follows go-flags.
4343
type CmdOptions struct {
44-
Byfile bool `long:"by-file" description:"report results for every encountered source file"`
44+
ByFile bool `long:"by-file" description:"report results for every encountered source file"`
4545
SortTag string `long:"sort" default:"code" description:"sort based on a certain column" choice:"name" choice:"files" choice:"blank" choice:"comment" choice:"code"`
4646
OutputType string `long:"output-type" default:"default" description:"output type [values: default,cloc-xml,sloccount,json]"`
4747
ExcludeExt string `long:"exclude-ext" description:"exclude file name extensions (separated commas)"`
@@ -73,7 +73,7 @@ func (o *outputBuilder) WriteHeader() {
7373
headerLen := 28
7474
header := languageHeader
7575

76-
if o.opts.Byfile {
76+
if o.opts.ByFile {
7777
headerLen = maxPathLen + 1
7878
rowLen = maxPathLen + len(commonHeader) + 2
7979
header = fileHeader
@@ -91,7 +91,7 @@ func (o *outputBuilder) WriteFooter() {
9191

9292
if o.opts.OutputType == OutputTypeDefault {
9393
fmt.Printf("%.[2]*[1]s\n", defaultOutputSeparator, rowLen)
94-
if o.opts.Byfile {
94+
if o.opts.ByFile {
9595
fmt.Printf("%-[1]*[2]v %6[3]v %14[4]v %14[5]v %14[6]v\n",
9696
maxPathLen, "TOTAL", total.Total, total.Blanks, total.Comments, total.Code)
9797
} else {
@@ -173,7 +173,7 @@ func (o *outputBuilder) WriteResult() {
173173
clocLangs := o.result.Languages
174174
total := o.result.Total
175175

176-
if o.opts.Byfile {
176+
if o.opts.ByFile {
177177
writeResultWithByFile(o.opts, o.result)
178178
} else {
179179
var sortedLanguages gocloc.Languages
@@ -251,7 +251,7 @@ func main() {
251251
}
252252

253253
// check sort tag option with other options
254-
if opts.Byfile && opts.SortTag == "files" {
254+
if opts.ByFile && opts.SortTag == "files" {
255255
fmt.Println("`--sort files` option cannot be used in conjunction with the `--by-file` option")
256256
os.Exit(1)
257257
}

file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func AnalyzeReader(filename string, language *Language, file io.Reader, opts *Cl
8080
}
8181

8282
isFirstLine := true
83-
inComments := [][2]string{}
83+
var inComments [][2]string
8484
buf := getByteSlice()
8585
defer putByteSlice(buf)
8686
scanner := bufio.NewScanner(file)

language.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111
"strings"
1212
"unicode"
1313

14-
enry "github.com/go-enry/go-enry/v2"
14+
"github.com/go-enry/go-enry/v2"
1515
)
1616

17-
// ClocLanguage is provide for xml-cloc and json format.
17+
// ClocLanguage is provided for xml-cloc and json format.
1818
type ClocLanguage struct {
1919
Name string `xml:"name,attr" json:"name,omitempty"`
2020
FilesCount int32 `xml:"files_count,attr" json:"files"`
@@ -449,7 +449,7 @@ func NewLanguage(name string, lineComments []string, multiLines [][]string) *Lan
449449
}
450450

451451
func lang2exts(lang string) (exts string) {
452-
es := []string{}
452+
var es []string
453453
for ext, l := range Exts {
454454
if lang == l {
455455
switch lang {
@@ -477,10 +477,10 @@ type DefinedLanguages struct {
477477
Langs map[string]*Language
478478
}
479479

480-
// GetFormattedString return DefinedLanguages as a human readable string.
480+
// GetFormattedString return DefinedLanguages as a human-readable string.
481481
func (langs *DefinedLanguages) GetFormattedString() string {
482482
var buf bytes.Buffer
483-
printLangs := []string{}
483+
var printLangs []string
484484
for _, lang := range langs.Langs {
485485
printLangs = append(printLangs, lang.Name)
486486
}

utils.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ func trimBOM(line string) string {
2020
}
2121

2222
func containsComment(line string, multiLines [][]string) bool {
23-
for _, mlcomm := range multiLines {
24-
for _, comm := range mlcomm {
23+
for _, comments := range multiLines {
24+
for _, comm := range comments {
2525
if strings.Contains(line, comm) {
2626
return true
2727
}
@@ -69,11 +69,11 @@ func isVCSDir(path string) bool {
6969

7070
func checkDefaultIgnore(path string, info os.FileInfo, isVCS bool) bool {
7171
if info.IsDir() {
72-
// directory is ignore
72+
// directory is ignored
7373
return true
7474
}
7575
if !isVCS && isVCSDir(path) {
76-
// vcs file or directory is ignore
76+
// vcs file or directory is ignored
7777
return true
7878
}
7979

@@ -101,7 +101,7 @@ func checkOptionMatch(path string, info os.FileInfo, opts *ClocOptions) bool {
101101
return true
102102
}
103103

104-
// getAllFiles return all of the files to be analyzed in paths.
104+
// getAllFiles return all the files to be analyzed in paths.
105105
func getAllFiles(paths []string, languages *DefinedLanguages, opts *ClocOptions) (result map[string]*Language, err error) {
106106
result = make(map[string]*Language, 0)
107107
fileCache := make(map[string]struct{})

xml.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (x *XMLResult) Encode() {
5858
}
5959

6060
// NewXMLResultFromCloc returns XMLResult with default data set.
61-
func NewXMLResultFromCloc(total *Language, sortedLanguages Languages, option XMLResultType) *XMLResult {
61+
func NewXMLResultFromCloc(total *Language, sortedLanguages Languages, _ XMLResultType) *XMLResult {
6262
var langs []ClocLanguage
6363
for _, language := range sortedLanguages {
6464
c := ClocLanguage{

0 commit comments

Comments
 (0)