Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
66fbf2fc
C
Coca
项目概览
Phodal
/
Coca
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Coca
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
66fbf2fc
编写于
12月 30, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: rename support to infrastructure
上级
cf61e1dc
变更
45
隐藏空白更改
内联
并排
Showing
45 changed file
with
101 addition
and
105 deletion
+101
-105
cmd/analysis.go
cmd/analysis.go
+1
-1
cmd/api.go
cmd/api.go
+1
-1
cmd/bs.go
cmd/bs.go
+3
-3
cmd/call.go
cmd/call.go
+1
-1
cmd/cmd_util/file.go
cmd/cmd_util/file.go
+2
-2
cmd/concept.go
cmd/concept.go
+1
-1
cmd/count.go
cmd/count.go
+3
-3
cmd/evaluate.go
cmd/evaluate.go
+1
-1
cmd/git.go
cmd/git.go
+2
-2
cmd/rcall.go
cmd/rcall.go
+1
-1
cmd/refactor.go
cmd/refactor.go
+2
-2
cmd/suggest.go
cmd/suggest.go
+2
-2
cmd/tbs.go
cmd/tbs.go
+4
-4
cmd/todo.go
cmd/todo.go
+3
-3
coca.go
coca.go
+1
-1
core/adapter/api/java_api_app.go
core/adapter/api/java_api_app.go
+3
-3
core/adapter/bs/bad_smell_app.go
core/adapter/bs/bad_smell_app.go
+2
-2
core/adapter/call/java_call_app.go
core/adapter/call/java_call_app.go
+3
-3
core/adapter/helper.go
core/adapter/helper.go
+5
-5
core/adapter/identifier/java_identifier_app.go
core/adapter/identifier/java_identifier_app.go
+3
-3
core/domain/arch/arch_app_test.go
core/domain/arch/arch_app_test.go
+2
-2
core/domain/call_graph/call_graph_test.go
core/domain/call_graph/call_graph_test.go
+2
-2
core/domain/call_graph/rcall/rcall_graph.go
core/domain/call_graph/rcall/rcall_graph.go
+2
-2
core/domain/call_graph/rcall/rcall_graph_test.go
core/domain/call_graph/rcall/rcall_graph_test.go
+2
-2
core/domain/concept/concept_analyser.go
core/domain/concept/concept_analyser.go
+4
-4
core/domain/concept/concept_analyser_test.go
core/domain/concept/concept_analyser_test.go
+2
-2
core/domain/count/count_app_test.go
core/domain/count/count_app_test.go
+2
-2
core/domain/evaluate/analyser.go
core/domain/evaluate/analyser.go
+2
-2
core/domain/evaluate/analyser_test.go
core/domain/evaluate/analyser_test.go
+5
-5
core/domain/evaluate/evaluator/service.go
core/domain/evaluate/evaluator/service.go
+13
-3
core/domain/gitt/changelog.go
core/domain/gitt/changelog.go
+2
-2
core/domain/gitt/gitt.go
core/domain/gitt/gitt.go
+1
-1
core/domain/refactor/move_class/move_class_app.go
core/domain/refactor/move_class/move_class_app.go
+1
-1
core/domain/refactor/rename/rename_method.go
core/domain/refactor/rename/rename_method.go
+2
-2
core/domain/refactor/unused/remove_unused_import.go
core/domain/refactor/unused/remove_unused_import.go
+3
-3
core/domain/refactor/unused_classes/unused_classes_app_test.go
...domain/refactor/unused_classes/unused_classes_app_test.go
+2
-2
core/domain/suggest/suggest_app_test.go
core/domain/suggest/suggest_app_test.go
+2
-2
core/domain/tbs/tbs_app_test.go
core/domain/tbs/tbs_app_test.go
+2
-2
core/domain/todo/todo_app.go
core/domain/todo/todo_app.go
+2
-2
core/infrastructure/apriori/apriori.go
core/infrastructure/apriori/apriori.go
+0
-0
core/infrastructure/file_analysis_helper.go
core/infrastructure/file_analysis_helper.go
+1
-1
core/infrastructure/file_helper.go
core/infrastructure/file_helper.go
+1
-1
core/infrastructure/string_array.go
core/infrastructure/string_array.go
+1
-1
core/infrastructure/word_freq.go
core/infrastructure/word_freq.go
+1
-1
core/support/tech_stop_words.go
core/support/tech_stop_words.go
+0
-14
未找到文件。
cmd/analysis.go
浏览文件 @
66fbf2fc
...
...
@@ -4,7 +4,7 @@ import (
"encoding/json"
.
"github.com/phodal/coca/core/adapter/call"
.
"github.com/phodal/coca/core/adapter/identifier"
.
"github.com/phodal/coca/core/
support
"
.
"github.com/phodal/coca/core/
infrastructure
"
"github.com/spf13/cobra"
)
...
...
cmd/api.go
浏览文件 @
66fbf2fc
...
...
@@ -9,7 +9,7 @@ import (
"github.com/phodal/coca/core/adapter"
.
"github.com/phodal/coca/core/adapter/api"
"github.com/phodal/coca/core/domain/call_graph"
.
"github.com/phodal/coca/core/
support
"
.
"github.com/phodal/coca/core/
infrastructure
"
"github.com/spf13/cobra"
"log"
"os"
...
...
cmd/bs.go
浏览文件 @
66fbf2fc
...
...
@@ -3,7 +3,7 @@ package cmd
import
(
"encoding/json"
"github.com/phodal/coca/core/adapter/bs"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"github.com/spf13/cobra"
"sort"
"strings"
...
...
@@ -38,7 +38,7 @@ var badsmellCmd = &cobra.Command{
bsModel
,
_
=
json
.
MarshalIndent
(
sortSmells
,
""
,
"
\t
"
)
}
support
.
WriteToCocaFile
(
"bs.json"
,
string
(
bsModel
))
infrastructure
.
WriteToCocaFile
(
"bs.json"
,
string
(
bsModel
))
},
}
...
...
@@ -69,7 +69,7 @@ func isSmellHaveSize(key string) bool {
"longMethod"
,
"dataClass"
,
}
return
support
.
Contains
(
smellList
,
key
)
return
infrastructure
.
Contains
(
smellList
,
key
)
}
func
init
()
{
...
...
cmd/call.go
浏览文件 @
66fbf2fc
...
...
@@ -6,7 +6,7 @@ import (
"github.com/phodal/coca/config"
.
"github.com/phodal/coca/core/domain/call_graph"
"github.com/phodal/coca/core/models"
.
"github.com/phodal/coca/core/
support
"
.
"github.com/phodal/coca/core/
infrastructure
"
"github.com/spf13/cobra"
"log"
"strings"
...
...
cmd/cmd_util/file.go
浏览文件 @
66fbf2fc
...
...
@@ -5,14 +5,14 @@ import (
"fmt"
"github.com/phodal/coca/config"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"log"
"os/exec"
)
func
GetDepsFromJson
(
depPath
string
)
[]
models
.
JClassNode
{
var
parsedDeps
[]
models
.
JClassNode
file
:=
support
.
ReadFile
(
depPath
)
file
:=
infrastructure
.
ReadFile
(
depPath
)
if
file
==
nil
{
log
.
Fatal
(
"lost file:"
+
depPath
)
}
...
...
cmd/concept.go
浏览文件 @
66fbf2fc
...
...
@@ -6,7 +6,7 @@ import (
"github.com/phodal/coca/config"
"github.com/phodal/coca/core/domain/concept"
"github.com/phodal/coca/core/models"
.
"github.com/phodal/coca/core/
support
"
.
"github.com/phodal/coca/core/
infrastructure
"
"github.com/spf13/cobra"
"log"
"os"
...
...
cmd/count.go
浏览文件 @
66fbf2fc
...
...
@@ -6,7 +6,7 @@ import (
"github.com/phodal/coca/config"
"github.com/phodal/coca/core/domain/count"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"github.com/spf13/cobra"
"log"
"os"
...
...
@@ -34,7 +34,7 @@ var countCmd = &cobra.Command{
return
}
file
:=
support
.
ReadFile
(
dependence
)
file
:=
infrastructure
.
ReadFile
(
dependence
)
if
file
==
nil
{
log
.
Fatal
(
"lost file:"
+
dependence
)
}
...
...
@@ -43,7 +43,7 @@ var countCmd = &cobra.Command{
callMap
:=
count
.
BuildCallMap
(
cparsedDeps
)
callMapSort
:=
support
.
RankByWordCount
(
callMap
)
callMapSort
:=
infrastructure
.
RankByWordCount
(
callMap
)
if
countCmdConfig
.
Top
>
0
{
callMapSort
=
callMapSort
[
:
countCmdConfig
.
Top
]
...
...
cmd/evaluate.go
浏览文件 @
66fbf2fc
...
...
@@ -7,7 +7,7 @@ import (
"github.com/phodal/coca/config"
"github.com/phodal/coca/core/domain/evaluate"
"github.com/phodal/coca/core/models"
.
"github.com/phodal/coca/core/
support
"
.
"github.com/phodal/coca/core/
infrastructure
"
"github.com/spf13/cobra"
"log"
"os"
...
...
cmd/git.go
浏览文件 @
66fbf2fc
...
...
@@ -5,7 +5,7 @@ import (
"fmt"
"github.com/olekukonko/tablewriter"
.
"github.com/phodal/coca/core/domain/gitt"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"github.com/spf13/cobra"
"io/ioutil"
"log"
...
...
@@ -33,7 +33,7 @@ var gitCmd = &cobra.Command{
message
:=
getCommitMessage
()
commitMessages
:=
BuildMessageByInput
(
message
)
cModel
,
_
:=
json
.
MarshalIndent
(
commitMessages
,
""
,
"
\t
"
)
support
.
WriteToCocaFile
(
"commits.json"
,
string
(
cModel
))
infrastructure
.
WriteToCocaFile
(
"commits.json"
,
string
(
cModel
))
if
*&
gitCmdConfig
.
ShowSummary
{
ShowChangeLogSummary
(
commitMessages
)
...
...
cmd/rcall.go
浏览文件 @
66fbf2fc
...
...
@@ -6,7 +6,7 @@ import (
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/config"
"github.com/phodal/coca/core/domain/call_graph/rcall"
.
"github.com/phodal/coca/core/
support
"
.
"github.com/phodal/coca/core/
infrastructure
"
"github.com/spf13/cobra"
"log"
"strings"
...
...
cmd/refactor.go
浏览文件 @
66fbf2fc
...
...
@@ -6,7 +6,7 @@ import (
.
"github.com/phodal/coca/core/domain/refactor/move_class"
.
"github.com/phodal/coca/core/domain/refactor/rename"
.
"github.com/phodal/coca/core/domain/refactor/unused"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"github.com/spf13/cobra"
)
...
...
@@ -30,7 +30,7 @@ var refactorCmd = &cobra.Command{
}
if
dependence
!=
""
&&
rename
!=
""
{
file
:=
support
.
ReadFile
(
dependence
)
file
:=
infrastructure
.
ReadFile
(
dependence
)
if
file
==
nil
{
return
}
...
...
cmd/suggest.go
浏览文件 @
66fbf2fc
...
...
@@ -5,7 +5,7 @@ import (
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/config"
"github.com/phodal/coca/core/domain/suggest"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"github.com/spf13/cobra"
"log"
"os"
...
...
@@ -21,7 +21,7 @@ var suggestCmd = &cobra.Command{
Long
:
``
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
parsedDeps
=
nil
depFile
:=
support
.
ReadFile
(
apiCmdConfig
.
DependencePath
)
depFile
:=
infrastructure
.
ReadFile
(
apiCmdConfig
.
DependencePath
)
if
depFile
==
nil
{
log
.
Fatal
(
"lost deps"
)
}
...
...
cmd/tbs.go
浏览文件 @
66fbf2fc
...
...
@@ -8,7 +8,7 @@ import (
"github.com/phodal/coca/core/adapter/call"
"github.com/phodal/coca/core/domain/tbs"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"github.com/spf13/cobra"
"os"
"strconv"
...
...
@@ -28,7 +28,7 @@ var tbsCmd = &cobra.Command{
Short
:
"generate tests bad smell"
,
Long
:
``
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
files
:=
support
.
GetJavaTestFiles
(
tbsCmdConfig
.
Path
)
files
:=
infrastructure
.
GetJavaTestFiles
(
tbsCmdConfig
.
Path
)
var
identifiers
[]
models
.
JIdentifier
identifiers
=
adapter
.
LoadTestIdentify
(
files
)
...
...
@@ -43,7 +43,7 @@ var tbsCmd = &cobra.Command{
classNodes
:=
analysisApp
.
AnalysisFiles
(
identifiers
,
files
,
classes
)
nodeContent
,
_
:=
json
.
MarshalIndent
(
classNodes
,
""
,
"
\t
"
)
support
.
WriteToCocaFile
(
"tdeps.json"
,
string
(
nodeContent
))
infrastructure
.
WriteToCocaFile
(
"tdeps.json"
,
string
(
nodeContent
))
app
:=
tbs
.
NewTbsApp
()
result
:=
app
.
AnalysisPath
(
classNodes
,
identifiersMap
)
...
...
@@ -60,7 +60,7 @@ var tbsCmd = &cobra.Command{
resultContent
,
_
=
json
.
MarshalIndent
(
tbsMap
,
""
,
"
\t
"
)
}
support
.
WriteToCocaFile
(
"tbs.json"
,
string
(
resultContent
))
infrastructure
.
WriteToCocaFile
(
"tbs.json"
,
string
(
resultContent
))
if
len
(
result
)
<=
20
{
table
:=
tablewriter
.
NewWriter
(
os
.
Stdout
)
...
...
cmd/todo.go
浏览文件 @
66fbf2fc
...
...
@@ -5,7 +5,7 @@ import (
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/core/domain/todo"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"github.com/spf13/cobra"
"os"
"strings"
...
...
@@ -30,7 +30,7 @@ var todoCmd = &cobra.Command{
todos
:=
app
.
AnalysisPath
(
path
)
simple
,
_
:=
json
.
MarshalIndent
(
todos
,
""
,
"
\t
"
)
support
.
WriteToCocaFile
(
"simple-todos.json"
,
string
(
simple
))
infrastructure
.
WriteToCocaFile
(
"simple-todos.json"
,
string
(
simple
))
fmt
.
Println
(
"Todos Count"
,
len
(
todos
))
...
...
@@ -38,7 +38,7 @@ var todoCmd = &cobra.Command{
gitTodos
:=
app
.
BuildWithGitHistory
(
todos
)
cModel
,
_
:=
json
.
MarshalIndent
(
todos
,
""
,
"
\t
"
)
support
.
WriteToCocaFile
(
"todos.json"
,
string
(
cModel
))
infrastructure
.
WriteToCocaFile
(
"todos.json"
,
string
(
cModel
))
table
:=
tablewriter
.
NewWriter
(
os
.
Stdout
)
table
.
SetHeader
([]
string
{
"Date"
,
"Author"
,
"Messages"
,
"FileName"
,
"Line"
})
...
...
coca.go
浏览文件 @
66fbf2fc
...
...
@@ -5,6 +5,6 @@ import (
)
func
main
()
{
//defer profile.Start(
profile.MemProfile, profile.ProfilePath("."), profile.NoShutdownHook
)
//defer profile.Start(
).Stop(
)
cmd
.
Execute
()
}
core/adapter/api/java_api_app.go
浏览文件 @
66fbf2fc
...
...
@@ -2,7 +2,7 @@ package api
import
(
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
"path/filepath"
...
...
@@ -14,14 +14,14 @@ type JavaApiApp struct {
}
func
(
j
*
JavaApiApp
)
AnalysisPath
(
codeDir
string
,
parsedDeps
[]
models
.
JClassNode
,
identifiersMap
map
[
string
]
models
.
JIdentifier
,
diMap
map
[
string
]
string
)
[]
RestApi
{
files
:=
support
.
GetJavaFiles
(
codeDir
)
files
:=
infrastructure
.
GetJavaFiles
(
codeDir
)
for
index
:=
range
files
{
file
:=
files
[
index
]
displayName
:=
filepath
.
Base
(
file
)
fmt
.
Println
(
"Start parse java call: "
+
displayName
)
parser
:=
support
.
ProcessFile
(
file
)
parser
:=
infrastructure
.
ProcessFile
(
file
)
context
:=
parser
.
CompilationUnit
()
listener
:=
NewJavaApiListener
(
identifiersMap
,
diMap
)
...
...
core/adapter/bs/bad_smell_app.go
浏览文件 @
66fbf2fc
...
...
@@ -5,7 +5,7 @@ import (
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
models2
"github.com/phodal/coca/core/adapter/bs/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"os"
"path/filepath"
"strconv"
...
...
@@ -54,7 +54,7 @@ func (j *BadSmellApp) AnalysisPath(codeDir string, ignoreRules []string) []BadSm
}
bsModel
,
_
:=
json
.
MarshalIndent
(
nodeInfos
,
""
,
"
\t
"
)
support
.
WriteToCocaFile
(
"nodeInfos.json"
,
string
(
bsModel
))
infrastructure
.
WriteToCocaFile
(
"nodeInfos.json"
,
string
(
bsModel
))
bsList
:=
analysisBadSmell
(
nodeInfos
)
...
...
core/adapter/call/java_call_app.go
浏览文件 @
66fbf2fc
...
...
@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"path/filepath"
)
...
...
@@ -16,7 +16,7 @@ func NewJavaCallApp() JavaCallApp {
}
func
(
j
*
JavaCallApp
)
AnalysisPath
(
codeDir
string
,
classes
[]
string
,
identNodes
[]
models
.
JIdentifier
)
[]
models
.
JClassNode
{
files
:=
support
.
GetJavaFiles
(
codeDir
)
files
:=
infrastructure
.
GetJavaFiles
(
codeDir
)
return
j
.
AnalysisFiles
(
identNodes
,
files
,
classes
)
}
...
...
@@ -32,7 +32,7 @@ func (j *JavaCallApp) AnalysisFiles(identNodes []models.JIdentifier, files []str
displayName
:=
filepath
.
Base
(
file
)
fmt
.
Println
(
"Start parse java call: "
+
displayName
)
parser
:=
support
.
ProcessFile
(
file
)
parser
:=
infrastructure
.
ProcessFile
(
file
)
context
:=
parser
.
CompilationUnit
()
listener
:=
NewJavaCallListener
(
identMap
,
file
)
...
...
core/adapter/helper.go
浏览文件 @
66fbf2fc
...
...
@@ -4,7 +4,7 @@ import (
"encoding/json"
"github.com/phodal/coca/core/adapter/identifier"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
)
func
BuildIdentifierMap
(
identifiers
[]
models
.
JIdentifier
)
map
[
string
]
models
.
JIdentifier
{
...
...
@@ -19,13 +19,13 @@ func BuildIdentifierMap(identifiers []models.JIdentifier) map[string]models.JIde
func
LoadIdentify
(
importPath
string
)
[]
models
.
JIdentifier
{
var
identifiers
[]
models
.
JIdentifier
apiContent
:=
support
.
ReadCocaFile
(
"identify.json"
)
apiContent
:=
infrastructure
.
ReadCocaFile
(
"identify.json"
)
if
apiContent
==
nil
||
string
(
apiContent
)
==
"null"
{
identifierApp
:=
new
(
identifier
.
JavaIdentifierApp
)
ident
:=
identifierApp
.
AnalysisPath
(
importPath
)
identModel
,
_
:=
json
.
MarshalIndent
(
ident
,
""
,
"
\t
"
)
support
.
WriteToCocaFile
(
"identify.json"
,
string
(
identModel
))
infrastructure
.
WriteToCocaFile
(
"identify.json"
,
string
(
identModel
))
return
*&
ident
}
...
...
@@ -37,14 +37,14 @@ func LoadIdentify(importPath string) []models.JIdentifier {
func
LoadTestIdentify
(
files
[]
string
)
[]
models
.
JIdentifier
{
var
identifiers
[]
models
.
JIdentifier
apiContent
:=
support
.
ReadCocaFile
(
"tidentify.json"
)
apiContent
:=
infrastructure
.
ReadCocaFile
(
"tidentify.json"
)
if
apiContent
==
nil
||
string
(
apiContent
)
==
"null"
{
identifierApp
:=
identifier
.
NewJavaIdentifierApp
()
ident
:=
identifierApp
.
AnalysisFiles
(
files
)
identModel
,
_
:=
json
.
MarshalIndent
(
ident
,
""
,
"
\t
"
)
support
.
WriteToCocaFile
(
"tidentify.json"
,
string
(
identModel
))
infrastructure
.
WriteToCocaFile
(
"tidentify.json"
,
string
(
identModel
))
return
*&
ident
}
...
...
core/adapter/identifier/java_identifier_app.go
浏览文件 @
66fbf2fc
...
...
@@ -3,7 +3,7 @@ package identifier
import
(
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
)
...
...
@@ -15,7 +15,7 @@ func NewJavaIdentifierApp() JavaIdentifierApp {
}
func
(
j
*
JavaIdentifierApp
)
AnalysisPath
(
codeDir
string
)
[]
models
.
JIdentifier
{
files
:=
support
.
GetJavaFiles
(
codeDir
)
files
:=
infrastructure
.
GetJavaFiles
(
codeDir
)
return
j
.
AnalysisFiles
(
files
)
}
...
...
@@ -23,7 +23,7 @@ func (j *JavaIdentifierApp) AnalysisFiles(files []string) []models.JIdentifier {
var
nodeInfos
[]
models
.
JIdentifier
=
nil
for
_
,
file
:=
range
files
{
parser
:=
support
.
ProcessFile
(
file
)
parser
:=
infrastructure
.
ProcessFile
(
file
)
context
:=
parser
.
CompilationUnit
()
listener
:=
NewJavaIdentifierListener
()
...
...
core/domain/arch/arch_app_test.go
浏览文件 @
66fbf2fc
...
...
@@ -7,7 +7,7 @@ import (
"github.com/phodal/coca/core/adapter/call"
"github.com/phodal/coca/core/adapter/identifier"
"github.com/phodal/coca/core/domain/arch/tequila"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"io"
"path/filepath"
"reflect"
...
...
@@ -49,7 +49,7 @@ func TestConceptAnalyser_Analysis(t *testing.T) {
g
.
Expect
(
len
(
graph
.
SubGraphs
.
SubGraphs
))
.
To
(
Equal
(
3
))
jsonContent
,
_
:=
json
.
MarshalIndent
(
results
,
""
,
"
\t
"
)
content
:=
support
.
ReadFile
(
filepath
.
FromSlash
(
codePath
+
"/"
+
"results.json"
))
content
:=
infrastructure
.
ReadFile
(
filepath
.
FromSlash
(
codePath
+
"/"
+
"results.json"
))
g
.
Expect
(
JSONBytesEqual
(
jsonContent
,
content
))
.
To
(
Equal
(
true
))
}
...
...
core/domain/call_graph/call_graph_test.go
浏览文件 @
66fbf2fc
...
...
@@ -5,7 +5,7 @@ import (
.
"github.com/onsi/gomega"
"github.com/phodal/coca/core/domain/call_graph"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"path/filepath"
"testing"
)
...
...
@@ -19,7 +19,7 @@ func Test_should_generate_correct_files(t *testing.T) {
codePath
:=
"../../../_fixtures/call_api_test.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
support
.
ReadFile
(
codePath
)
file
:=
infrastructure
.
ReadFile
(
codePath
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
dotContent
:=
analyser
.
Analysis
(
"com.phodal.pholedge.book.BookController.createBook"
,
*&
parsedDeps
)
...
...
core/domain/call_graph/rcall/rcall_graph.go
浏览文件 @
66fbf2fc
...
...
@@ -3,7 +3,7 @@ package rcall
import
(
"github.com/phodal/coca/core/domain/call_graph"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"encoding/json"
)
...
...
@@ -19,7 +19,7 @@ func (c RCallGraph) Analysis(funcName string, clzs []models.JClassNode) string {
rcallMap
:=
BuildRCallMethodMap
(
clzs
,
projectMethodMap
)
mapJson
,
_
:=
json
.
MarshalIndent
(
rcallMap
,
""
,
"
\t
"
)
support
.
WriteToCocaFile
(
"rcallmap.json"
,
string
(
mapJson
))
infrastructure
.
WriteToCocaFile
(
"rcallmap.json"
,
string
(
mapJson
))
chain
:=
c
.
buildRCallChain
(
funcName
,
rcallMap
)
...
...
core/domain/call_graph/rcall/rcall_graph_test.go
浏览文件 @
66fbf2fc
...
...
@@ -3,7 +3,7 @@ package rcall
import
(
"encoding/json"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"log"
"testing"
...
...
@@ -15,7 +15,7 @@ func TestRCallGraph_Analysis(t *testing.T) {
var
parsedDeps
[]
models
.
JClassNode
analyser
:=
NewRCallGraph
()
file
:=
support
.
ReadFile
(
"../../../../_fixtures/call_api_test.json"
)
file
:=
infrastructure
.
ReadFile
(
"../../../../_fixtures/call_api_test.json"
)
if
file
==
nil
{
log
.
Fatal
(
"lost file"
)
}
...
...
core/domain/concept/concept_analyser.go
浏览文件 @
66fbf2fc
...
...
@@ -4,7 +4,7 @@ import (
"github.com/phodal/coca/config"
languages2
"github.com/phodal/coca/core/domain/call_graph/stop_words/languages"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
)
type
ConceptAnalyser
struct
{
...
...
@@ -18,11 +18,11 @@ func (c ConceptAnalyser) run() {
}
func
(
c
ConceptAnalyser
)
Analysis
(
clzs
*
[]
models
.
JClassNode
)
support
.
PairList
{
func
(
c
ConceptAnalyser
)
Analysis
(
clzs
*
[]
models
.
JClassNode
)
infrastructure
.
PairList
{
return
buildMethodsFromDeps
(
*
clzs
)
}
func
buildMethodsFromDeps
(
clzs
[]
models
.
JClassNode
)
support
.
PairList
{
func
buildMethodsFromDeps
(
clzs
[]
models
.
JClassNode
)
infrastructure
.
PairList
{
var
methodsName
[]
string
var
methodStr
string
for
_
,
clz
:=
range
clzs
{
...
...
@@ -37,7 +37,7 @@ func buildMethodsFromDeps(clzs []models.JClassNode) support.PairList {
words
=
removeNormalWords
(
words
)
wordCounts
:=
support
.
RankByWordCount
(
words
)
wordCounts
:=
infrastructure
.
RankByWordCount
(
words
)
return
wordCounts
}
...
...
core/domain/concept/concept_analyser_test.go
浏览文件 @
66fbf2fc
...
...
@@ -3,7 +3,7 @@ package concept
import
(
"encoding/json"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"log"
"path/filepath"
"testing"
...
...
@@ -19,7 +19,7 @@ func TestConceptAnalyser_Analysis(t *testing.T) {
codePath
:=
"../../../_fixtures/call_api_test.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
support
.
ReadFile
(
codePath
)
file
:=
infrastructure
.
ReadFile
(
codePath
)
if
file
==
nil
{
log
.
Fatal
(
"lost file"
)
}
...
...
core/domain/count/count_app_test.go
浏览文件 @
66fbf2fc
...
...
@@ -4,7 +4,7 @@ import (
"encoding/json"
.
"github.com/onsi/gomega"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"path/filepath"
"testing"
)
...
...
@@ -14,7 +14,7 @@ func TestBuildCallMap(t *testing.T) {
var
parsedDeps
[]
models
.
JClassNode
codePath
:=
"../../../_fixtures/count/call.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
support
.
ReadFile
(
codePath
)
file
:=
infrastructure
.
ReadFile
(
codePath
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
callMap
:=
BuildCallMap
(
parsedDeps
)
...
...
core/domain/evaluate/analyser.go
浏览文件 @
66fbf2fc
...
...
@@ -3,7 +3,7 @@ package evaluate
import
(
"github.com/phodal/coca/core/domain/evaluate/evaluator"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"gonum.org/v1/gonum/stat"
"strings"
)
...
...
@@ -49,7 +49,7 @@ func (a Analyser) Analysis(classNodes []models.JClassNode, identifiers []models.
for
_
,
method
:=
range
ident
.
Methods
{
result
.
Summary
.
MethodCount
++
if
support
.
Contains
(
method
.
Modifiers
,
"static"
)
{
if
infrastructure
.
Contains
(
method
.
Modifiers
,
"static"
)
{
result
.
Summary
.
StaticMethodCount
++
}
...
...
core/domain/evaluate/analyser_test.go
浏览文件 @
66fbf2fc
...
...
@@ -8,7 +8,7 @@ import (
"github.com/phodal/coca/core/adapter/identifier"
"github.com/phodal/coca/core/domain/evaluate/evaluator"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"path/filepath"
"testing"
)
...
...
@@ -20,7 +20,7 @@ func TestAnalyser_Analysis(t *testing.T) {
analyser
:=
NewEvaluateAnalyser
()
codePath
:=
"../../../_fixtures/evaluate/service.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
support
.
ReadFile
(
codePath
)
file
:=
infrastructure
.
ReadFile
(
codePath
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
analyser
.
Analysis
(
parsedDeps
,
nil
)
...
...
@@ -35,7 +35,7 @@ func Test_Service_LifeCycle(t *testing.T) {
analyser
:=
NewEvaluateAnalyser
()
codePath
:=
"../../../_fixtures/evaluate/service_lifecycle.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
support
.
ReadFile
(
codePath
)
file
:=
infrastructure
.
ReadFile
(
codePath
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
result
:=
analyser
.
Analysis
(
parsedDeps
,
nil
)
...
...
@@ -52,7 +52,7 @@ func Test_Service_Same_Return_Type(t *testing.T) {
analyser
:=
NewEvaluateAnalyser
()
codePath
:=
"../../../_fixtures/evaluate/service_same_return_type.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
support
.
ReadFile
(
codePath
)
file
:=
infrastructure
.
ReadFile
(
codePath
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
results
:=
analyser
.
Analysis
(
parsedDeps
,
nil
)
...
...
@@ -67,7 +67,7 @@ func Test_Long_Parameters(t *testing.T) {
analyser
:=
NewEvaluateAnalyser
()
codePath
:=
"../../../_fixtures/evaluate/service_long_parameters.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
support
.
ReadFile
(
codePath
)
file
:=
infrastructure
.
ReadFile
(
codePath
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
result
:=
analyser
.
Analysis
(
parsedDeps
,
nil
)
...
...
core/domain/evaluate/evaluator/service.go
浏览文件 @
66fbf2fc
package
evaluator
import
(
"github.com/phodal/coca/config"
"github.com/phodal/coca/core/infrastructure/apriori"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/support"
"github.com/phodal/coca/core/support/apriori"
"strings"
)
...
...
@@ -103,7 +103,7 @@ func (s Service) buildLifecycle(methodNameArray [][]string) map[string][]string
}
firstWord
:=
nameArray
[
0
]
if
!
(
support
.
IsTechStopWords
(
firstWord
))
{
if
!
(
IsTechStopWords
(
firstWord
))
{
nameMap
[
firstWord
]
=
append
(
nameMap
[
firstWord
],
strings
.
Join
(
nameArray
,
""
))
}
if
len
(
nameMap
[
firstWord
])
>
1
{
...
...
@@ -114,6 +114,16 @@ func (s Service) buildLifecycle(methodNameArray [][]string) map[string][]string
return
hadLifecycle
}
func
IsTechStopWords
(
firstWord
string
)
bool
{
for
_
,
word
:=
range
config
.
TechStopWords
{
if
word
==
firstWord
{
return
true
;
}
}
return
false
;
}
func
(
s
Service
)
enableLifecycle
()
bool
{
return
true
}
...
...
core/domain/gitt/changelog.go
浏览文件 @
66fbf2fc
...
...
@@ -2,7 +2,7 @@ package gitt
import
(
"fmt"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"regexp"
)
...
...
@@ -16,7 +16,7 @@ var (
func
ShowChangeLogSummary
(
commits
[]
CommitMessage
)
{
changeMap
:=
BuildChangeMap
(
commits
)
for
key
,
value
:=
range
changeMap
{
sortValue
:=
support
.
RankByWordCount
(
value
)
sortValue
:=
infrastructure
.
RankByWordCount
(
value
)
maxSize
:=
len
(
sortValue
)
if
maxSize
>
10
{
maxSize
=
10
...
...
core/domain/gitt/gitt.go
浏览文件 @
66fbf2fc
...
...
@@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/phodal/coca/core/
support
/apriori"
"github.com/phodal/coca/core/
infrastructure
/apriori"
"log"
"sort"
"strings"
...
...
core/domain/refactor/move_class/move_class_app.go
浏览文件 @
66fbf2fc
...
...
@@ -6,7 +6,7 @@ import (
"github.com/antlr/antlr4/runtime/Go/antlr"
base2
"github.com/phodal/coca/core/domain/refactor/base"
models2
"github.com/phodal/coca/core/domain/refactor/base/models"
utils2
"github.com/phodal/coca/core/
support
"
utils2
"github.com/phodal/coca/core/
infrastructure
"
"io"
"io/ioutil"
"log"
...
...
core/domain/refactor/rename/rename_method.go
浏览文件 @
66fbf2fc
...
...
@@ -3,7 +3,7 @@ package unused
import
(
support3
"github.com/phodal/coca/core/domain/refactor/rename/support"
.
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"io/ioutil"
"log"
"strings"
...
...
@@ -25,7 +25,7 @@ func RenameMethodApp(deps []JClassNode, p string) *RemoveMethodApp {
}
func
(
j
*
RemoveMethodApp
)
Start
()
{
configBytes
:=
support
.
ReadFile
(
configPath
)
configBytes
:=
infrastructure
.
ReadFile
(
configPath
)
if
configBytes
==
nil
{
return
}
...
...
core/domain/refactor/unused/remove_unused_import.go
浏览文件 @
66fbf2fc
...
...
@@ -5,7 +5,7 @@ import (
"github.com/antlr/antlr4/runtime/Go/antlr"
base2
"github.com/phodal/coca/core/domain/refactor/base"
models2
"github.com/phodal/coca/core/domain/refactor/base/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"io/ioutil"
"os"
"path/filepath"
...
...
@@ -25,7 +25,7 @@ func NewRemoveUnusedImportApp(pPath string) *RemoveUnusedImportApp {
}
func
(
j
*
RemoveUnusedImportApp
)
Analysis
()
[]
models2
.
JFullIdentifier
{
files
:=
support
.
GetJavaFiles
(
configPath
)
files
:=
infrastructure
.
GetJavaFiles
(
configPath
)
var
nodes
[]
models2
.
JFullIdentifier
=
nil
for
index
:=
range
files
{
...
...
@@ -35,7 +35,7 @@ func (j *RemoveUnusedImportApp) Analysis() []models2.JFullIdentifier {
displayName
:=
filepath
.
Base
(
file
)
fmt
.
Println
(
"Start parse java call: "
+
displayName
)
parser
:=
support
.
ProcessFile
(
file
)
parser
:=
infrastructure
.
ProcessFile
(
file
)
context
:=
parser
.
CompilationUnit
()
node
:=
models2
.
NewJFullIdentifier
()
...
...
core/domain/refactor/unused_classes/unused_classes_app_test.go
浏览文件 @
66fbf2fc
...
...
@@ -4,7 +4,7 @@ import (
"encoding/json"
.
"github.com/onsi/gomega"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"path/filepath"
"testing"
)
...
...
@@ -16,7 +16,7 @@ func TestRefactoring(t *testing.T) {
var
parsedDeps
[]
models
.
JClassNode
codePath
:=
"../../../../_fixtures/count/call.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
support
.
ReadFile
(
codePath
)
file
:=
infrastructure
.
ReadFile
(
codePath
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
results
:=
Refactoring
(
parsedDeps
)
...
...
core/domain/suggest/suggest_app_test.go
浏览文件 @
66fbf2fc
...
...
@@ -3,7 +3,7 @@ package suggest
import
(
"encoding/json"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"log"
"path/filepath"
"testing"
...
...
@@ -18,7 +18,7 @@ func TestConceptAnalyser_Analysis(t *testing.T) {
analyser
:=
NewSuggestApp
()
codePath
:=
"../../../_fixtures/suggest/factory/factory_suggest.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
support
.
ReadFile
(
codePath
)
file
:=
infrastructure
.
ReadFile
(
codePath
)
if
file
==
nil
{
log
.
Fatal
(
"lost file"
)
}
...
...
core/domain/tbs/tbs_app_test.go
浏览文件 @
66fbf2fc
...
...
@@ -5,7 +5,7 @@ import (
"github.com/phodal/coca/core/adapter"
"github.com/phodal/coca/core/adapter/call"
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
"path/filepath"
"testing"
)
...
...
@@ -111,7 +111,7 @@ func TestTbsApp_CallAssertInClassTests(t *testing.T) {
}
func
buildTbsResult
(
codePath
string
)
[]
TestBadSmell
{
files
:=
support
.
GetJavaTestFiles
(
codePath
)
files
:=
infrastructure
.
GetJavaTestFiles
(
codePath
)
var
identifiers
[]
models
.
JIdentifier
identifiers
=
adapter
.
LoadTestIdentify
(
files
)
...
...
core/domain/todo/todo_app.go
浏览文件 @
66fbf2fc
...
...
@@ -5,7 +5,7 @@ import (
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/core/domain/gitt"
"github.com/phodal/coca/core/domain/todo/astitodo"
"github.com/phodal/coca/core/
support
"
"github.com/phodal/coca/core/
infrastructure
"
.
"github.com/phodal/coca/languages/java"
"log"
"os/exec"
...
...
@@ -66,7 +66,7 @@ func (a TodoApp) BuildWithGitHistory(todos []*astitodo.TODO) []TodoDetail {
func
buildComment
(
path
string
)
[]
*
astitodo
.
TODO
{
var
todos
[]
*
astitodo
.
TODO
files
:=
support
.
GetJavaFiles
(
path
)
files
:=
infrastructure
.
GetJavaFiles
(
path
)
for
index
:=
range
files
{
file
:=
files
[
index
]
...
...
core/
support
/apriori/apriori.go
→
core/
infrastructure
/apriori/apriori.go
浏览文件 @
66fbf2fc
文件已移动
core/
support
/file_analysis_helper.go
→
core/
infrastructure
/file_analysis_helper.go
浏览文件 @
66fbf2fc
package
support
package
infrastructure
import
(
"fmt"
...
...
core/
support
/file_helper.go
→
core/
infrastructure
/file_helper.go
浏览文件 @
66fbf2fc
package
support
package
infrastructure
import
(
"fmt"
...
...
core/
support
/string_array.go
→
core/
infrastructure
/string_array.go
浏览文件 @
66fbf2fc
package
support
package
infrastructure
import
"sort"
...
...
core/
support
/word_freq.go
→
core/
infrastructure
/word_freq.go
浏览文件 @
66fbf2fc
package
support
package
infrastructure
import
"sort"
...
...
core/support/tech_stop_words.go
已删除
100644 → 0
浏览文件 @
cf61e1dc
package
support
import
"github.com/phodal/coca/config"
func
IsTechStopWords
(
firstWord
string
)
bool
{
for
_
,
word
:=
range
config
.
TechStopWords
{
if
word
==
firstWord
{
return
true
;
}
}
return
false
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录