styles: update output styles to markdown

上级 100281a8
......@@ -2,7 +2,6 @@ package cmd
import (
"encoding/json"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/cmd/config"
"github.com/phodal/coca/pkg/application/api"
......@@ -73,7 +72,7 @@ var apiCmd = &cobra.Command{
}
if apiCmdConfig.ShowCount {
table := tablewriter.NewWriter(output)
table := cmd_util.NewOutput(output)
table.SetHeader([]string{"Size", "Method", "URI", "Caller"})
......
......@@ -39,4 +39,4 @@ func Test_ApiWithSortRemove(t *testing.T) {
Golden: "testdata/api_sort_remove.txt",
}}
RunTestCmd(t, tests)
}
\ No newline at end of file
}
package cmd_util
import (
"github.com/olekukonko/tablewriter"
"io"
)
func NewOutput(output io.Writer) *tablewriter.Table {
table := tablewriter.NewWriter(output)
table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false})
table.SetCenterSeparator("|")
return table
}
......@@ -2,7 +2,6 @@ package cmd
import (
"encoding/json"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/cmd/config"
"github.com/phodal/coca/pkg/application/count"
......@@ -41,7 +40,7 @@ var countCmd = &cobra.Command{
callMapSort = callMapSort[:countCmdConfig.Top]
}
table := tablewriter.NewWriter(output)
table := cmd_util.NewOutput(output)
table.SetHeader([]string{"Refs Count", "method"})
for _, count := range callMapSort {
......
......@@ -2,7 +2,7 @@ package cmd
import (
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/pkg/adapter/cocafile"
"github.com/phodal/coca/pkg/application/analysis"
"github.com/phodal/coca/pkg/application/deps"
......@@ -50,7 +50,7 @@ var depCmd = &cobra.Command{
results := app.AnalysisPath(path, classNodes)
fmt.Fprintln(output, "unused")
table := tablewriter.NewWriter(output)
table := cmd_util.NewOutput(output)
table.SetHeader([]string{"GroupId", "ArtifactId", "Scope"})
for _, dep := range results {
table.Append([]string{dep.GroupId, dep.ArtifactId, dep.Scope})
......
......@@ -3,7 +3,6 @@ package cmd
import (
"encoding/json"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/cmd/config"
"github.com/phodal/coca/pkg/application/evaluate"
......@@ -51,7 +50,7 @@ var evaluateCmd = &cobra.Command{
}
func buildOutput(result evaluator.EvaluateModel) {
table := tablewriter.NewWriter(output)
table := cmd_util.NewOutput(output)
table.SetHeader([]string{"Type", "Count", "Level", "Total", "Rate"})
classCount := result.Summary.ClassCount
......
......@@ -3,7 +3,6 @@ package cmd
import (
"encoding/json"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
. "github.com/phodal/coca/pkg/application/git"
"github.com/spf13/cobra"
......@@ -41,9 +40,9 @@ var gitCmd = &cobra.Command{
isFullMessage := cmd.Flag("full").Value.String() == "true"
size := gitCmdConfig.Size
if cmd.Flag("basic").Value.String() == "true" {
table := tablewriter.NewWriter(output)
table := cmd_util.NewOutput(output)
if cmd.Flag("basic").Value.String() == "true" {
basicSummary := BasicSummary(commitMessages)
table.SetHeader([]string{"Statistic", "Number"})
table.Append([]string{"Commits", strconv.Itoa(basicSummary.Commits)})
......@@ -54,8 +53,6 @@ var gitCmd = &cobra.Command{
}
if cmd.Flag("team").Value.String() == "true" {
table := tablewriter.NewWriter(output)
teamSummary := GetTeamSummary(commitMessages)
table.SetHeader([]string{"EntityName", "RevsCount", "AuthorCount"})
......@@ -69,8 +66,6 @@ var gitCmd = &cobra.Command{
}
if cmd.Flag("age").Value.String() == "true" {
table := tablewriter.NewWriter(output)
ages := CalculateCodeAge(commitMessages)
var agesDisplay []CodeAgeDisplay
for _, info := range ages {
......@@ -92,8 +87,6 @@ var gitCmd = &cobra.Command{
}
if cmd.Flag("top").Value.String() == "true" {
table := tablewriter.NewWriter(output)
authors := GetTopAuthors(commitMessages)
table.SetHeader([]string{"Author", "CommitCount", "LineCount"})
......
......@@ -13,4 +13,4 @@ func TestGit(t *testing.T) {
Golden: "",
}}
RunTestCmd(t, tests)
}
\ No newline at end of file
}
......@@ -2,7 +2,6 @@ package cmd
import (
"encoding/json"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/cmd/config"
"github.com/phodal/coca/pkg/application/suggest"
......@@ -30,7 +29,7 @@ var suggestCmd = &cobra.Command{
app := suggest.NewSuggestApp()
results := app.AnalysisPath(parsedDeps)
table := tablewriter.NewWriter(output)
table := cmd_util.NewOutput(output)
table.SetHeader([]string{"Class", "Pattern", "Reason"})
for _, result := range results {
......
......@@ -19,4 +19,4 @@ func TestSuggest(t *testing.T) {
Golden: "testdata/suggest_normal.txt",
}}
RunTestCmd(t, tests)
}
\ No newline at end of file
}
......@@ -3,7 +3,6 @@ package cmd
import (
"encoding/json"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/pkg/adapter/cocafile"
"github.com/phodal/coca/pkg/application/analysis"
......@@ -47,7 +46,6 @@ var tbsCmd = &cobra.Command{
result := app.AnalysisPath(classNodes, identifiersMap)
fmt.Fprintf(output, "Test Bad Smell nums: %d\n", len(result))
resultContent, _ := json.MarshalIndent(result, "", "\t")
if tbsCmdConfig.IsSort {
......@@ -60,9 +58,8 @@ var tbsCmd = &cobra.Command{
}
cmd_util.WriteToCocaFile("tbs.json", string(resultContent))
if len(result) <= 20 {
table := tablewriter.NewWriter(output)
table := cmd_util.NewOutput(output)
table.SetHeader([]string{"Type", "FileName", "Line"})
for _, result := range result {
......
......@@ -12,4 +12,4 @@ func TestTbs(t *testing.T) {
Golden: "testdata/tbs_normal.txt",
}}
RunTestCmd(t, tests)
}
\ No newline at end of file
}
+------+--------+-------------+-----------------------------------------------------+
| SIZE | METHOD | URI | CALLER |
+------+--------+-------------+-----------------------------------------------------+
|------|--------|-------------|-----------------------------------------------------|
| 2 | POST | /books | com.phodal.pholedge.book.BookController.createBook |
| 2 | PUT | /books/{id} | com.phodal.pholedge.book.BookController.updateBook |
| 2 | GET | /books/ | com.phodal.pholedge.book.BookController.getBookList |
| 2 | GET | /books/{id} | com.phodal.pholedge.book.BookController.getBookById |
+------+--------+-------------+-----------------------------------------------------+
+------+--------+-------------+----------------------------+
| SIZE | METHOD | URI | CALLER |
+------+--------+-------------+----------------------------+
|------|--------|-------------|----------------------------|
| 2 | POST | /books | BookController.createBook |
| 2 | PUT | /books/{id} | BookController.updateBook |
| 2 | GET | /books/ | BookController.getBookList |
| 2 | GET | /books/{id} | BookController.getBookById |
+------+--------+-------------+----------------------------+
+------------+------------------------------------------------------------+
| REFS COUNT | METHOD |
+------------+------------------------------------------------------------+
|------------|------------------------------------------------------------|
| 1 | study.huhao.demo.infrastructure.persistence.blog.BlogPO.of |
+------------+------------------------------------------------------------+
unused
+---------------------------+-------------------------------------------+--------------------+
| GROUPID | ARTIFACTID | SCOPE |
+---------------------------+-------------------------------------------+--------------------+
|---------------------------|-------------------------------------------|--------------------|
| org.flywaydb | flyway-core | implementation |
| org.springframework.cloud | spring-cloud-starter-zipkin | implementation |
| org.springframework.cloud | spring-cloud-starter-zookeeper-config | implementation |
| io.projectreactor | reactor-test | testImplementation |
| org.springframework.cloud | spring-cloud-starter-contract-stub-runner | testImplementation |
| org.springframework.cloud | spring-cloud-starter-contract-verifier | testImplementation |
+---------------------------+-------------------------------------------+--------------------+
unused
+---------------------------+----------------------------------------+---------+
| GROUPID | ARTIFACTID | SCOPE |
+---------------------------+----------------------------------------+---------+
|---------------------------|----------------------------------------|---------|
| org.flywaydb | flyway-core | |
| mysql | mysql-connector-java | runtime |
| org.springframework.cloud | spring-cloud-starter-contract-verifier | test |
+---------------------------+----------------------------------------+---------+
+--------------------------------+-------+-----------------------+-------+----------+
| TYPE | COUNT | LEVEL | TOTAL | RATE |
+--------------------------------+-------+-----------------------+-------+----------+
|--------------------------------|-------|-----------------------|-------|----------|
| Nullable / Return Null | 0 | Method | 6 | 0.00% |
| Utils | 0 | Class | 14 | 0.00% |
| Static Method | 1 | Method | 6 | 0.00% |
......@@ -8,4 +7,3 @@
| Method Num. Std Dev / 标准差 | 6 | Class | - | 0.646206 |
| Average Method Length | 0 | Without Getter/Setter | 0 | NaN |
| Method Length Std Dev / 标准差 | 6 | Method | - | NaN |
+--------------------------------+-------+-----------------------+-------+----------+
+------------+------------------+--------------------------------+
| CLASS | PATTERN | REASON |
+------------+------------------+--------------------------------+
|------------|------------------|--------------------------------|
| BeeBuilder | factory, builder | too many constructor, too many |
| | | parameters |
| Insect | factory | too many constructor |
| Bee | factory, builder | complex constructor, too |
| | | many constructor, too many |
| | | parameters |
+------------+------------------+--------------------------------+
Test Bad Smell nums: 12
+------------------------+---------------------------------------------------+------+
| TYPE | FILENAME | LINE |
+------------------------+---------------------------------------------------+------+
|------------------------|---------------------------------------------------|------|
| DuplicateAssertTest | ../_fixtures/tbs/code/DuplicateAssertTest.java | 9 |
| EmptyTest | ../_fixtures/tbs/code/EmptyTest.java | 8 |
| IgnoreTest | ../_fixtures/tbs/code/IgnoreTest.java | 0 |
......@@ -14,4 +13,3 @@ Test Bad Smell nums: 12
| RedundantAssertionTest | ../_fixtures/tbs/code/SleepyTest.java | 7 |
| EmptyTest | ../_fixtures/tbs/code/UnknownTest.java | 7 |
| UnknownTest | ../_fixtures/tbs/code/UnknownTest.java | 7 |
+------------------------+---------------------------------------------------+------+
......@@ -3,7 +3,6 @@ package cmd
import (
"encoding/json"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/pkg/application/todo"
"github.com/spf13/cobra"
......@@ -39,7 +38,7 @@ var todoCmd = &cobra.Command{
cModel, _ := json.MarshalIndent(todos, "", "\t")
cmd_util.WriteToCocaFile("todos.json", string(cModel))
table := tablewriter.NewWriter(output)
table := cmd_util.NewOutput(output)
table.SetHeader([]string{"Date", "Author", "Messages", "FileName", "Line"})
for _, todo := range gitTodos {
table.Append([]string{todo.Date, todo.Author, strings.Join(todo.Message, "\n"), todo.FileName, todo.Line})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册