mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-19 06:33:06 -03:00
Address code review feedback
Signed-off-by: Alexander Bezzubov <bzz@apache.org>
This commit is contained in:
@ -29,7 +29,7 @@ func main() {
|
||||
breakdownFlag := flag.Bool("breakdown", false, "")
|
||||
jsonFlag := flag.Bool("json", false, "")
|
||||
showVersion := flag.Bool("version", false, "Show the enry version information")
|
||||
allLangs := flag.Bool("all", false, "Show not only the files with programming languages (default) but all languages instead")
|
||||
allLangs := flag.Bool("all", false, "Show all files, including those identifed as non-programming languages")
|
||||
countMode := flag.String("mode", "byte", "the method used to count file size. Available options are: file, line and byte")
|
||||
limitKB := flag.Int64("limit", 16*1024, "Analyse first N KB of the file (-1 means no limit)")
|
||||
flag.Parse()
|
||||
@ -85,7 +85,7 @@ func main() {
|
||||
|
||||
if enry.IsVendor(relativePath) || enry.IsDotFile(relativePath) ||
|
||||
enry.IsDocumentation(relativePath) || enry.IsConfiguration(relativePath) {
|
||||
//TODO(bzz): skip enry.IsGeneratedPath() after https://github.com/src-d/enry/issues/213
|
||||
// TODO(bzz): skip enry.IsGeneratedPath() after https://github.com/src-d/enry/issues/213
|
||||
if f.IsDir() {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
@ -97,16 +97,16 @@ func main() {
|
||||
return nil
|
||||
}
|
||||
|
||||
//TODO(bzz): provide API that mimics lingust CLI output for
|
||||
// running ByExtension & ByFilename
|
||||
// reading the file, if that did not work
|
||||
// GetLanguage([]Strategy)
|
||||
// TODO(bzz): provide API that mimics lingust CLI output for
|
||||
// - running ByExtension & ByFilename
|
||||
// - reading the file, if that did not work
|
||||
// - GetLanguage([]Strategy)
|
||||
content, err := readFile(path, limit)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return nil
|
||||
}
|
||||
//TODO(bzz): skip enry.IsGeneratedContent() after https://github.com/src-d/enry/issues/213
|
||||
// TODO(bzz): skip enry.IsGeneratedContent() as well, after https://github.com/src-d/enry/issues/213
|
||||
|
||||
language := enry.GetLanguage(filepath.Base(path), content)
|
||||
if language == enry.OtherLanguage {
|
||||
@ -184,7 +184,7 @@ func (e filelistError) Error() string {
|
||||
|
||||
func printPercents(root string, fSummary map[string][]string, buff *bytes.Buffer, mode string) {
|
||||
// Select the way we quantify 'amount' of code.
|
||||
var reducer func(string, []string) (float64, filelistError)
|
||||
reducer := fileCountValues
|
||||
switch mode {
|
||||
case "file":
|
||||
reducer = fileCountValues
|
||||
@ -192,8 +192,6 @@ func printPercents(root string, fSummary map[string][]string, buff *bytes.Buffer
|
||||
reducer = lineCountValues
|
||||
case "byte":
|
||||
reducer = byteCountValues
|
||||
default:
|
||||
reducer = fileCountValues
|
||||
}
|
||||
|
||||
// Reduce the list of files to a quantity of file type.
|
||||
@ -204,7 +202,6 @@ func printPercents(root string, fSummary map[string][]string, buff *bytes.Buffer
|
||||
fileValues = make(map[string]float64)
|
||||
)
|
||||
for fType, files := range fSummary {
|
||||
//FIXME(bzz): all files here have relative paths
|
||||
val, err := reducer(root, files)
|
||||
if err != nil {
|
||||
unreadableFiles = append(unreadableFiles, err...)
|
||||
|
Reference in New Issue
Block a user