Skip to content

Commit

Permalink
Merge pull request #71 from hhatto/fix-lint-warnings
Browse files Browse the repository at this point in the history
Fix lint warnings
  • Loading branch information
hhatto committed Jul 24, 2023
2 parents 80d89c9 + d4bce40 commit 147945b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions cmd/gocloc/main.go
Expand Up @@ -8,7 +8,7 @@ import (
"strings"

"github.com/hhatto/gocloc"
flags "github.com/jessevdk/go-flags"
"github.com/jessevdk/go-flags"
)

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

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

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

if o.opts.Byfile {
if o.opts.ByFile {
writeResultWithByFile(o.opts, o.result)
} else {
var sortedLanguages gocloc.Languages
Expand Down Expand Up @@ -251,7 +251,7 @@ func main() {
}

// check sort tag option with other options
if opts.Byfile && opts.SortTag == "files" {
if opts.ByFile && opts.SortTag == "files" {
fmt.Println("`--sort files` option cannot be used in conjunction with the `--by-file` option")
os.Exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion file.go
Expand Up @@ -80,7 +80,7 @@ func AnalyzeReader(filename string, language *Language, file io.Reader, opts *Cl
}

isFirstLine := true
inComments := [][2]string{}
var inComments [][2]string
buf := getByteSlice()
defer putByteSlice(buf)
scanner := bufio.NewScanner(file)
Expand Down
10 changes: 5 additions & 5 deletions language.go
Expand Up @@ -11,10 +11,10 @@ import (
"strings"
"unicode"

enry "github.com/go-enry/go-enry/v2"
"github.com/go-enry/go-enry/v2"
)

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

func lang2exts(lang string) (exts string) {
es := []string{}
var es []string
for ext, l := range Exts {
if lang == l {
switch lang {
Expand Down Expand Up @@ -477,10 +477,10 @@ type DefinedLanguages struct {
Langs map[string]*Language
}

// GetFormattedString return DefinedLanguages as a human readable string.
// GetFormattedString return DefinedLanguages as a human-readable string.
func (langs *DefinedLanguages) GetFormattedString() string {
var buf bytes.Buffer
printLangs := []string{}
var printLangs []string
for _, lang := range langs.Langs {
printLangs = append(printLangs, lang.Name)
}
Expand Down
10 changes: 5 additions & 5 deletions utils.go
Expand Up @@ -20,8 +20,8 @@ func trimBOM(line string) string {
}

func containsComment(line string, multiLines [][]string) bool {
for _, mlcomm := range multiLines {
for _, comm := range mlcomm {
for _, comments := range multiLines {
for _, comm := range comments {
if strings.Contains(line, comm) {
return true
}
Expand Down Expand Up @@ -69,11 +69,11 @@ func isVCSDir(path string) bool {

func checkDefaultIgnore(path string, info os.FileInfo, isVCS bool) bool {
if info.IsDir() {
// directory is ignore
// directory is ignored
return true
}
if !isVCS && isVCSDir(path) {
// vcs file or directory is ignore
// vcs file or directory is ignored
return true
}

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

// getAllFiles return all of the files to be analyzed in paths.
// getAllFiles return all the files to be analyzed in paths.
func getAllFiles(paths []string, languages *DefinedLanguages, opts *ClocOptions) (result map[string]*Language, err error) {
result = make(map[string]*Language, 0)
fileCache := make(map[string]struct{})
Expand Down
2 changes: 1 addition & 1 deletion xml.go
Expand Up @@ -58,7 +58,7 @@ func (x *XMLResult) Encode() {
}

// NewXMLResultFromCloc returns XMLResult with default data set.
func NewXMLResultFromCloc(total *Language, sortedLanguages Languages, option XMLResultType) *XMLResult {
func NewXMLResultFromCloc(total *Language, sortedLanguages Languages, _ XMLResultType) *XMLResult {
var langs []ClocLanguage
for _, language := range sortedLanguages {
c := ClocLanguage{
Expand Down

0 comments on commit 147945b

Please sign in to comment.