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

refactor: extract model

上级 cab546e7
......@@ -2,7 +2,6 @@ package cmd
import (
"encoding/json"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/config"
......@@ -68,7 +67,6 @@ var apiCmd = &cobra.Command{
restFieldsApi := filterApi(apiPrefix, restApis)
fmt.Println(restApis)
analyser := call_graph.NewCallGraph()
dotContent, counts := analyser.AnalysisByFiles(restFieldsApi, parsedDeps, diMap)
......
......@@ -69,7 +69,7 @@ func isSmellHaveSize(key string) bool {
"longMethod",
"dataClass",
}
return infrastructure.Contains(smellList, key)
return infrastructure.StringArrayContains(smellList, key)
}
func init() {
......
......@@ -49,7 +49,7 @@ func (a Analyser) Analysis(classNodes []domain.JClassNode, identifiers []domain.
for _, method := range ident.Methods {
result.Summary.MethodCount++
if infrastructure.Contains(method.Modifiers, "static") {
if infrastructure.StringArrayContains(method.Modifiers, "static") {
result.Summary.StaticMethodCount++
}
......
......@@ -70,7 +70,8 @@ func (s Service) Evaluate(result *EvaluateModel, node domain.JClassNode) {
if s.enableAbstractParameters() {
for _, method := range node.Methods {
if len(method.Parameters) >= 4 {
PARAMETERR_LENGTH_LIMIT := 4
if len(method.Parameters) >= PARAMETERR_LENGTH_LIMIT {
longParameterList = append(longParameterList, method)
}
}
......
package domain
type Annotation struct {
QualifiedName string
ValuePairs []AnnotationKeyValue
}
type AnnotationKeyValue struct {
Key string
Value string
}
func NewAnnotation() Annotation {
return *&Annotation{
QualifiedName: "",
ValuePairs: nil,
}
}
......@@ -17,24 +17,6 @@ type JMethod struct {
Creators []JClassNode
}
type Annotation struct {
QualifiedName string
ValuePairs []AnnotationKeyValue
}
type AnnotationKeyValue struct {
Key string
Value string
}
func NewAnnotation() Annotation {
return *&Annotation{
QualifiedName: "",
ValuePairs: nil,
}
}
// TODO support annnotation
func NewJMethod() JMethod {
return *&JMethod{
Name: "",
......@@ -50,11 +32,6 @@ func NewJMethod() JMethod {
}
}
type JParameter struct {
Name string
Type string
}
type JMethodInfo struct {
Name string
Type string
......
package domain
type JParameter struct {
Name string
Type string
}
......@@ -2,7 +2,7 @@ package infrastructure
import "sort"
func Contains(s []string, searchterm string) bool {
func StringArrayContains(s []string, searchterm string) bool {
i := sort.SearchStrings(s, searchterm)
return i < len(s) && s[i] == searchterm
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册