Skip to content

Commit

Permalink
feat: [tbs] add sort by type cmd & fix mockito issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 29, 2019
1 parent 0b81891 commit 354931a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cmd/tbs.go
Expand Up @@ -15,7 +15,8 @@ import (
)

type TbsCmdConfig struct {
Path string
Path string
IsSort bool
}

var (
Expand Down Expand Up @@ -49,9 +50,19 @@ var tbsCmd = &cobra.Command{

fmt.Println("Test Bad Smell nums: ", len(result))
resultContent, _ := json.MarshalIndent(result, "", "\t")

if tbsCmdConfig.IsSort {
var tbsMap = make(map[string][]tbs.TestBadSmell)
for _, tbs := range result {
tbsMap[tbs.Type] = append(tbsMap[tbs.Type], tbs)
}

resultContent, _ = json.MarshalIndent(tbsMap, "", "\t")
}

support.WriteToCocaFile("tbs.json", string(resultContent))

if len(result) <= 20 {
if len(result) <= 20 {
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Type", "FileName", "Line"})

Expand All @@ -68,4 +79,5 @@ func init() {
rootCmd.AddCommand(tbsCmd)

tbsCmd.PersistentFlags().StringVarP(&tbsCmdConfig.Path, "path", "p", ".", "example -p core/main")
tbsCmd.PersistentFlags().BoolVarP(&tbsCmdConfig.IsSort, "sort", "s", false, "-s")
}
1 change: 1 addition & 0 deletions core/domain/tbs/tbs_app.go
Expand Up @@ -75,6 +75,7 @@ func hasAssertion(methodName string) bool {
"maynotbe", // ArchUnit,
"is", // RestAssured,
"spec", // RestAssured,
"verify", // Mockito,
}

for _, assertion := range assertionList {
Expand Down

0 comments on commit 354931a

Please sign in to comment.