未验证 提交 d825e524 编写于 作者: P Phodal Huang

feat: add cloc

上级 2772fb89
......@@ -30,6 +30,18 @@ Available Commands:
coca analysis -p [PATH]
```
### Find Bad Smells
```
coca bs -p examples/api -s type
```
### Code Line Count
```
coca cloc
```
### Build Deps Tree
```
......
package cmd
import (
"fmt"
"github.com/boyter/scc/processor"
"github.com/spf13/cobra"
)
var clocCmd = &cobra.Command{
Use: "scc",
Short: "scc [FILE or DIRECTORY]",
Long: fmt.Sprintf("Sloc, Cloc and Code. Count lines of code in a directory with complexity estimation.\nVersion %s\nBen Boyter <ben@boyter.org> + Contributors", processor.Version),
Version: processor.Version,
Run: func(cmd *cobra.Command, args []string) {
processor.DirFilePaths = args
processor.ConfigureGc()
processor.ConfigureLazy(true)
processor.Process()
},
}
func init() {
rootCmd.AddCommand(clocCmd)
flags := clocCmd.PersistentFlags()
flags.Int64Var(
&processor.AverageWage,
"avg-wage",
56286,
"average wage value used for basic COCOMO calculation",
)
flags.BoolVar(
&processor.DisableCheckBinary,
"binary",
false,
"disable binary file detection",
)
flags.BoolVar(
&processor.Files,
"by-file",
false,
"display output for every file",
)
flags.BoolVar(
&processor.Ci,
"ci",
false,
"enable CI output settings where stdout is ASCII",
)
flags.BoolVar(
&processor.Ignore,
"no-ignore",
false,
"disables .ignore file logic",
)
flags.BoolVar(
&processor.GitIgnore,
"no-gitignore",
false,
"disables .gitignore file logic",
)
flags.BoolVar(
&processor.Debug,
"debug",
false,
"enable debug output",
)
flags.StringSliceVar(
&processor.PathDenyList,
"exclude-dir",
[]string{".git", ".hg", ".svn"},
"directories to exclude",
)
flags.IntVar(
&processor.GcFileCount,
"file-gc-count",
10000,
"number of files to parse before turning the GC on",
)
flags.StringVarP(
&processor.Format,
"format",
"f",
"tabular",
"set output format [tabular, wide, json, csv, cloc-yaml]",
)
flags.StringSliceVarP(
&processor.AllowListExtensions,
"include-ext",
"i",
[]string{},
"limit to file extensions [comma separated list: e.g. go,java,js]",
)
flags.BoolVarP(
&processor.Languages,
"languages",
"l",
false,
"print supported languages and extensions",
)
flags.BoolVar(
&processor.Cocomo,
"no-cocomo",
false,
"remove COCOMO calculation output",
)
flags.BoolVarP(
&processor.Complexity,
"no-complexity",
"c",
false,
"skip calculation of code complexity",
)
flags.BoolVarP(
&processor.Duplicates,
"no-duplicates",
"d",
false,
"remove duplicate files from stats and output",
)
flags.BoolVarP(
&processor.MinifiedGenerated,
"min-gen",
"z",
false,
"identify minified or generated files",
)
flags.BoolVar(
&processor.IgnoreMinifiedGenerate,
"no-min-gen",
false,
"ignore minified or generated files in output (implies --min-gen)",
)
flags.IntVar(
&processor.MinifiedGeneratedLineByteLength,
"min-gen-line-length",
255,
"number of bytes per average line for file to be considered minified or generated",
)
flags.StringArrayVarP(
&processor.Exclude,
"not-match",
"M",
[]string{},
"ignore files and directories matching regular expression",
)
flags.StringVarP(
&processor.FileOutput,
"output",
"o",
"",
"output filename (default stdout)",
)
flags.StringVarP(
&processor.SortBy,
"sort",
"s",
"files",
"column to sort by [files, name, lines, blanks, code, comments, complexity]",
)
flags.BoolVarP(
&processor.Trace,
"trace",
"t",
false,
"enable trace output (not recommended when processing multiple files)",
)
flags.BoolVarP(
&processor.Verbose,
"verbose",
"v",
false,
"verbose output",
)
flags.BoolVarP(
&processor.More,
"wide",
"w",
false,
"wider output with additional statistics (implies --complexity)",
)
flags.BoolVar(
&processor.NoLarge,
"no-large",
false,
"ignore files over certain byte and line size set by max-line-count and max-byte-count",
)
flags.Int64Var(
&processor.LargeLineCount,
"large-line-count",
40000,
"number of lines a file can contain before being removed from output",
)
flags.Int64Var(
&processor.LargeByteCount,
"large-byte-count",
1000000,
"number of bytes a file can contain before being removed from output",
)
}
......@@ -4,7 +4,11 @@ go 1.13
require (
github.com/antlr/antlr4 v0.0.0-20191031194250-3fcb6da1f690
github.com/boyter/scc v2.10.1+incompatible
github.com/dbaggerman/cuba v0.3.2 // indirect
github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20160105113617-38717d0a108c // indirect
github.com/onsi/ginkgo v1.10.3
github.com/onsi/gomega v1.7.1
github.com/spf13/cobra v0.0.5
......
......@@ -2,17 +2,19 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/antlr/antlr4 v0.0.0-20191031194250-3fcb6da1f690 h1:ZxuHyCRVyeoXhu/PK93BvZP66NoNIsSZzCykW5MezKc=
github.com/antlr/antlr4 v0.0.0-20191031194250-3fcb6da1f690/go.mod h1:T7PbCXFs94rrTttyxjbyT5+/1V8T2TYDejxUfHJjw1Y=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/boyter/scc v2.10.1+incompatible h1:0bg2TmmduZjvoSqz0dfF3W3jfibgEFv2XOsKItTjarU=
github.com/boyter/scc v2.10.1+incompatible/go.mod h1:VB5w4e0dahmIiKnpZ7LRh/sjauoY0BmCWjIzZcShNY0=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dbaggerman/cuba v0.3.2 h1:6ZbQX3FNvkocR222YyoAIZ8wi4avrb7JcJkPvVI2AS4=
github.com/dbaggerman/cuba v0.3.2/go.mod h1:t9Oo05XRZGcjaVqsA/gFeNAOm7DYZYNhI17unI5FlwY=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/go-ego/cedar v0.0.0-20191026170511-cf63283d1a1d h1:JUevAF3NSTCkqOPKK2pHMuAO4uy7IQDgUbaZ85lnZiI=
github.com/go-ego/cedar v0.0.0-20191026170511-cf63283d1a1d/go.mod h1:2tj8NEwz6OsMT56YhN7mL7dYCncJs7dOmz/Xki1ofCU=
github.com/go-ego/gse v0.0.0-20191212182315-b30156ea952e h1:Y3PLgnqXxfnAJA1myyb2W8KHpLUqcR9HOGDTgEYoU1U=
github.com/go-ego/gse v0.0.0-20191212182315-b30156ea952e/go.mod h1:CEs4Qx+i8pnxDPG0Tlbb1GqVI4NxCbgNHcy+lQiDyTQ=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
......@@ -22,15 +24,22 @@ github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334 h1:VHgatEHNcBFE
github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/karrick/godirwalk v1.10.12/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g=
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/monochromegane/go-gitignore v0.0.0-20160105113617-38717d0a108c h1:RRUev95N3Gq4Aog4avFzXJA2V8fgXmND+cvcH7KLMyk=
github.com/monochromegane/go-gitignore v0.0.0-20160105113617-38717d0a108c/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.10.3 h1:OoxbjfXVZyod1fmWYhI7SEyaD8B00ynP3T+D5GiyHOY=
github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.7.1 h1:K0jcRCwNQM3vFGh1ppMtDh/+7ApJrjldlX8fA0jDTLQ=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pkg/profile v1.3.0/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
......@@ -41,9 +50,11 @@ github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb6
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/vcaesar/tt v0.0.0-20191103173835-6896a351024b/go.mod h1:GHPxQYhn+7OgKakRusH7KJ0M5MhywoeLb8Fcffs/Gtg=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册