Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
8c05762f
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 搜索 >>
未验证
提交
8c05762f
编写于
12月 31, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fefactor: move file helper to cmd
上级
9314a956
变更
35
隐藏空白更改
内联
并排
Showing
35 changed file
with
74 addition
and
76 deletion
+74
-76
cmd/analysis.go
cmd/analysis.go
+3
-3
cmd/api.go
cmd/api.go
+4
-5
cmd/bs.go
cmd/bs.go
+2
-2
cmd/call.go
cmd/call.go
+2
-3
cmd/cmd_util/file.go
cmd/cmd_util/file.go
+1
-2
cmd/cmd_util/file_rw_helper.go
cmd/cmd_util/file_rw_helper.go
+1
-1
cmd/concept.go
cmd/concept.go
+2
-2
cmd/count.go
cmd/count.go
+2
-2
cmd/evaluate.go
cmd/evaluate.go
+4
-4
cmd/git.go
cmd/git.go
+2
-2
cmd/rcall.go
cmd/rcall.go
+2
-3
cmd/refactor.go
cmd/refactor.go
+2
-2
cmd/suggest.go
cmd/suggest.go
+2
-2
cmd/tbs.go
cmd/tbs.go
+4
-3
cmd/todo.go
cmd/todo.go
+3
-3
core/adapter/coca_file/file_analysis_helper.go
core/adapter/coca_file/file_analysis_helper.go
+0
-0
core/context/analysis/java_full_app.go
core/context/analysis/java_full_app.go
+1
-1
core/context/analysis/java_identifier_app.go
core/context/analysis/java_identifier_app.go
+1
-1
core/context/api/java_api_app.go
core/context/api/java_api_app.go
+1
-1
core/context/arch/arch_app_test.go
core/context/arch/arch_app_test.go
+2
-2
core/context/bs/bad_smell_app.go
core/context/bs/bad_smell_app.go
+3
-2
core/context/call/call_graph_test.go
core/context/call/call_graph_test.go
+2
-2
core/context/concept/concept_analyser_test.go
core/context/concept/concept_analyser_test.go
+2
-2
core/context/count/count_app_test.go
core/context/count/count_app_test.go
+2
-2
core/context/evaluate/analyser_test.go
core/context/evaluate/analyser_test.go
+5
-5
core/context/rcall/rcall_graph.go
core/context/rcall/rcall_graph.go
+2
-2
core/context/rcall/rcall_graph_test.go
core/context/rcall/rcall_graph_test.go
+2
-2
core/context/refactor/move_class/move_class_app.go
core/context/refactor/move_class/move_class_app.go
+1
-1
core/context/refactor/rename/rename_method.go
core/context/refactor/rename/rename_method.go
+2
-2
core/context/refactor/unused/remove_unused_import.go
core/context/refactor/unused/remove_unused_import.go
+1
-1
core/context/refactor/unused_classes/unused_classes_app_test.go
...ontext/refactor/unused_classes/unused_classes_app_test.go
+2
-2
core/context/suggest/suggest_app_test.go
core/context/suggest/suggest_app_test.go
+2
-2
core/context/tbs/tbs_app_test.go
core/context/tbs/tbs_app_test.go
+1
-1
core/context/todo/todo_app.go
core/context/todo/todo_app.go
+1
-1
core/infrastructure/ast/ident_helper.go
core/infrastructure/ast/ident_helper.go
+5
-5
未找到文件。
cmd/analysis.go
浏览文件 @
8c05762f
...
...
@@ -2,8 +2,8 @@ package cmd
import
(
"encoding/json"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/core/context/analysis"
"github.com/phodal/coca/core/infrastructure/coca_file"
"github.com/spf13/cobra"
)
...
...
@@ -27,7 +27,7 @@ var analysisCmd = &cobra.Command{
iNodes
:=
identifierApp
.
AnalysisPath
(
importPath
)
identModel
,
_
:=
json
.
MarshalIndent
(
iNodes
,
""
,
"
\t
"
)
c
oca_file
.
WriteToCocaFile
(
"identify.json"
,
string
(
identModel
))
c
md_util
.
WriteToCocaFile
(
"identify.json"
,
string
(
identModel
))
var
classes
[]
string
=
nil
...
...
@@ -39,7 +39,7 @@ var analysisCmd = &cobra.Command{
callNodes
:=
callApp
.
AnalysisPath
(
importPath
,
classes
,
iNodes
)
cModel
,
_
:=
json
.
MarshalIndent
(
callNodes
,
""
,
"
\t
"
)
c
oca_file
.
WriteToCocaFile
(
"deps.json"
,
string
(
cModel
))
c
md_util
.
WriteToCocaFile
(
"deps.json"
,
string
(
cModel
))
},
}
...
...
cmd/api.go
浏览文件 @
8c05762f
...
...
@@ -9,7 +9,6 @@ import (
"github.com/phodal/coca/core/context/call"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/ast"
"github.com/phodal/coca/core/infrastructure/coca_file"
"github.com/spf13/cobra"
"log"
"os"
...
...
@@ -46,7 +45,7 @@ var apiCmd = &cobra.Command{
apiPrefix
:=
apiCmdConfig
.
AggregateApi
parsedDeps
=
nil
depFile
:=
c
oca_file
.
ReadFile
(
depPath
)
depFile
:=
c
md_util
.
ReadFile
(
depPath
)
if
depFile
==
nil
{
log
.
Fatal
(
"lost deps"
)
}
...
...
@@ -56,7 +55,7 @@ var apiCmd = &cobra.Command{
if
*&
apiCmdConfig
.
ForceUpdate
{
forceUpdateApi
()
}
else
{
apiContent
:=
c
oca_file
.
ReadCocaFile
(
"apis.json"
)
apiContent
:=
c
md_util
.
ReadCocaFile
(
"apis.json"
)
if
apiContent
==
nil
{
forceUpdateApi
()
}
...
...
@@ -89,7 +88,7 @@ var apiCmd = &cobra.Command{
dotContent
=
replacePackage
(
dotContent
)
}
c
oca_file
.
WriteToCocaFile
(
"api.dot"
,
dotContent
)
c
md_util
.
WriteToCocaFile
(
"api.dot"
,
dotContent
)
cmd_util
.
ConvertToSvg
(
"api"
)
},
}
...
...
@@ -98,7 +97,7 @@ func forceUpdateApi() {
app
:=
new
(
api
.
JavaApiApp
)
restApis
=
app
.
AnalysisPath
(
apiCmdConfig
.
Path
,
parsedDeps
,
identifiersMap
,
diMap
)
cModel
,
_
:=
json
.
MarshalIndent
(
restApis
,
""
,
"
\t
"
)
c
oca_file
.
WriteToCocaFile
(
"apis.json"
,
string
(
cModel
))
c
md_util
.
WriteToCocaFile
(
"apis.json"
,
string
(
cModel
))
}
func
replacePackage
(
content
string
)
string
{
...
...
cmd/bs.go
浏览文件 @
8c05762f
...
...
@@ -2,9 +2,9 @@ package cmd
import
(
"encoding/json"
"github.com/phodal/coca/cmd/cmd_util"
bs2
"github.com/phodal/coca/core/context/bs"
"github.com/phodal/coca/core/domain/bs_domain"
"github.com/phodal/coca/core/infrastructure/coca_file"
"github.com/phodal/coca/core/infrastructure/string_helper"
"github.com/spf13/cobra"
"strings"
...
...
@@ -39,7 +39,7 @@ var badsmellCmd = &cobra.Command{
bsModel
,
_
=
json
.
MarshalIndent
(
sortSmells
,
""
,
"
\t
"
)
}
c
oca_file
.
WriteToCocaFile
(
"bs.json"
,
string
(
bsModel
))
c
md_util
.
WriteToCocaFile
(
"bs.json"
,
string
(
bsModel
))
},
}
...
...
cmd/call.go
浏览文件 @
8c05762f
...
...
@@ -6,7 +6,6 @@ import (
"github.com/phodal/coca/cmd/config"
.
"github.com/phodal/coca/core/context/call"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/coca_file"
"github.com/spf13/cobra"
"log"
"strings"
...
...
@@ -33,7 +32,7 @@ var callGraphCmd = &cobra.Command{
if
dependence
!=
""
{
analyser
:=
NewCallGraph
()
file
:=
c
oca_file
.
ReadFile
(
dependence
)
file
:=
c
md_util
.
ReadFile
(
dependence
)
if
file
==
nil
{
log
.
Fatal
(
"lost file:"
+
dependence
)
}
...
...
@@ -45,7 +44,7 @@ var callGraphCmd = &cobra.Command{
content
=
strings
.
ReplaceAll
(
content
,
remove
,
""
)
}
c
oca_file
.
WriteToCocaFile
(
"call.dot"
,
content
)
c
md_util
.
WriteToCocaFile
(
"call.dot"
,
content
)
cmd_util
.
ConvertToSvg
(
"call"
)
}
},
...
...
cmd/cmd_util/file.go
浏览文件 @
8c05762f
...
...
@@ -5,14 +5,13 @@ import (
"fmt"
"github.com/phodal/coca/cmd/config"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/coca_file"
"log"
"os/exec"
)
func
GetDepsFromJson
(
depPath
string
)
[]
domain
.
JClassNode
{
var
parsedDeps
[]
domain
.
JClassNode
file
:=
coca_file
.
ReadFile
(
depPath
)
file
:=
ReadFile
(
depPath
)
if
file
==
nil
{
log
.
Fatal
(
"lost file:"
+
depPath
)
}
...
...
c
ore/infrastructure/coca_file/file
_helper.go
→
c
md/cmd_util/file_rw
_helper.go
浏览文件 @
8c05762f
package
c
oca_file
package
c
md_util
import
(
"fmt"
...
...
cmd/concept.go
浏览文件 @
8c05762f
...
...
@@ -3,10 +3,10 @@ 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/core/context/concept"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/coca_file"
"github.com/spf13/cobra"
"log"
"os"
...
...
@@ -24,7 +24,7 @@ var conceptCmd = &cobra.Command{
if
dependence
!=
""
{
analyser
:=
concept
.
NewConceptAnalyser
()
file
:=
c
oca_file
.
ReadFile
(
dependence
)
file
:=
c
md_util
.
ReadFile
(
dependence
)
if
file
==
nil
{
log
.
Fatal
(
"lost file:"
+
dependence
)
}
...
...
cmd/count.go
浏览文件 @
8c05762f
...
...
@@ -3,10 +3,10 @@ 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/core/context/count"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/coca_file"
"github.com/phodal/coca/core/infrastructure/string_helper"
"github.com/spf13/cobra"
"log"
...
...
@@ -35,7 +35,7 @@ var countCmd = &cobra.Command{
return
}
file
:=
c
oca_file
.
ReadFile
(
dependence
)
file
:=
c
md_util
.
ReadFile
(
dependence
)
if
file
==
nil
{
log
.
Fatal
(
"lost file:"
+
dependence
)
}
...
...
cmd/evaluate.go
浏览文件 @
8c05762f
...
...
@@ -4,10 +4,10 @@ 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/core/context/evaluate"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/coca_file"
"github.com/spf13/cobra"
"log"
"os"
...
...
@@ -30,13 +30,13 @@ var evaluateCmd = &cobra.Command{
dependence
:=
*&
evaluateConfig
.
DependencePath
analyser
:=
evaluate
.
NewEvaluateAnalyser
()
file
:=
c
oca_file
.
ReadFile
(
dependence
)
file
:=
c
md_util
.
ReadFile
(
dependence
)
if
file
==
nil
{
log
.
Fatal
(
"lost file:"
+
dependence
)
}
var
identifiers
[]
domain
.
JIdentifier
identContent
:=
c
oca_file
.
ReadCocaFile
(
"identify.json"
)
identContent
:=
c
md_util
.
ReadCocaFile
(
"identify.json"
)
_
=
json
.
Unmarshal
(
identContent
,
&
identifiers
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
...
...
@@ -44,7 +44,7 @@ var evaluateCmd = &cobra.Command{
result
:=
analyser
.
Analysis
(
parsedDeps
,
identifiers
)
cModel
,
_
:=
json
.
MarshalIndent
(
result
,
""
,
"
\t
"
)
c
oca_file
.
WriteToCocaFile
(
"evaluate.json"
,
string
(
cModel
))
c
md_util
.
WriteToCocaFile
(
"evaluate.json"
,
string
(
cModel
))
table
:=
tablewriter
.
NewWriter
(
os
.
Stdout
)
table
.
SetHeader
([]
string
{
"Type"
,
"Count"
,
"Level"
,
"Total"
,
"Rate"
})
...
...
cmd/git.go
浏览文件 @
8c05762f
...
...
@@ -4,8 +4,8 @@ import (
"encoding/json"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
.
"github.com/phodal/coca/core/context/git"
"github.com/phodal/coca/core/infrastructure/coca_file"
"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
"
)
c
oca_file
.
WriteToCocaFile
(
"commits.json"
,
string
(
cModel
))
c
md_util
.
WriteToCocaFile
(
"commits.json"
,
string
(
cModel
))
if
*&
gitCmdConfig
.
ShowSummary
{
ShowChangeLogSummary
(
commitMessages
)
...
...
cmd/rcall.go
浏览文件 @
8c05762f
...
...
@@ -6,7 +6,6 @@ import (
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/cmd/config"
"github.com/phodal/coca/core/context/rcall"
"github.com/phodal/coca/core/infrastructure/coca_file"
"github.com/spf13/cobra"
"log"
"strings"
...
...
@@ -36,7 +35,7 @@ var reverseCmd = &cobra.Command{
}
analyser
:=
rcall
.
NewRCallGraph
()
file
:=
c
oca_file
.
ReadFile
(
dependence
)
file
:=
c
md_util
.
ReadFile
(
dependence
)
if
file
==
nil
{
log
.
Fatal
(
"lost file:"
+
dependence
)
}
...
...
@@ -50,7 +49,7 @@ var reverseCmd = &cobra.Command{
content
=
strings
.
ReplaceAll
(
content
,
remove
,
""
)
}
c
oca_file
.
WriteToCocaFile
(
"rcall.dot"
,
content
)
c
md_util
.
WriteToCocaFile
(
"rcall.dot"
,
content
)
cmd_util
.
ConvertToSvg
(
"call"
)
},
}
...
...
cmd/refactor.go
浏览文件 @
8c05762f
...
...
@@ -2,11 +2,11 @@ package cmd
import
(
"encoding/json"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/cmd/config"
.
"github.com/phodal/coca/core/context/refactor/move_class"
.
"github.com/phodal/coca/core/context/refactor/rename"
.
"github.com/phodal/coca/core/context/refactor/unused"
"github.com/phodal/coca/core/infrastructure/coca_file"
"github.com/spf13/cobra"
)
...
...
@@ -30,7 +30,7 @@ var refactorCmd = &cobra.Command{
}
if
dependence
!=
""
&&
rename
!=
""
{
file
:=
c
oca_file
.
ReadFile
(
dependence
)
file
:=
c
md_util
.
ReadFile
(
dependence
)
if
file
==
nil
{
return
}
...
...
cmd/suggest.go
浏览文件 @
8c05762f
...
...
@@ -3,9 +3,9 @@ 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/core/context/suggest"
"github.com/phodal/coca/core/infrastructure/coca_file"
"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
:=
c
oca_file
.
ReadFile
(
apiCmdConfig
.
DependencePath
)
depFile
:=
c
md_util
.
ReadFile
(
apiCmdConfig
.
DependencePath
)
if
depFile
==
nil
{
log
.
Fatal
(
"lost deps"
)
}
...
...
cmd/tbs.go
浏览文件 @
8c05762f
...
...
@@ -4,11 +4,12 @@ import (
"encoding/json"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/core/adapter/coca_file"
"github.com/phodal/coca/core/context/analysis"
"github.com/phodal/coca/core/context/tbs"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/ast"
"github.com/phodal/coca/core/infrastructure/coca_file"
"github.com/spf13/cobra"
"os"
"strconv"
...
...
@@ -43,7 +44,7 @@ var tbsCmd = &cobra.Command{
classNodes
:=
analysisApp
.
AnalysisFiles
(
identifiers
,
files
,
classes
)
nodeContent
,
_
:=
json
.
MarshalIndent
(
classNodes
,
""
,
"
\t
"
)
c
oca_file
.
WriteToCocaFile
(
"tdeps.json"
,
string
(
nodeContent
))
c
md_util
.
WriteToCocaFile
(
"tdeps.json"
,
string
(
nodeContent
))
app
:=
tbs
.
NewTbsApp
()
result
:=
app
.
AnalysisPath
(
classNodes
,
identifiersMap
)
...
...
@@ -60,7 +61,7 @@ var tbsCmd = &cobra.Command{
resultContent
,
_
=
json
.
MarshalIndent
(
tbsMap
,
""
,
"
\t
"
)
}
c
oca_file
.
WriteToCocaFile
(
"tbs.json"
,
string
(
resultContent
))
c
md_util
.
WriteToCocaFile
(
"tbs.json"
,
string
(
resultContent
))
if
len
(
result
)
<=
20
{
table
:=
tablewriter
.
NewWriter
(
os
.
Stdout
)
...
...
cmd/todo.go
浏览文件 @
8c05762f
...
...
@@ -4,8 +4,8 @@ import (
"encoding/json"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/core/context/todo"
"github.com/phodal/coca/core/infrastructure/coca_file"
"github.com/spf13/cobra"
"os"
"strings"
...
...
@@ -30,7 +30,7 @@ var todoCmd = &cobra.Command{
todos
:=
app
.
AnalysisPath
(
path
)
simple
,
_
:=
json
.
MarshalIndent
(
todos
,
""
,
"
\t
"
)
c
oca_file
.
WriteToCocaFile
(
"simple-todos.json"
,
string
(
simple
))
c
md_util
.
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
"
)
c
oca_file
.
WriteToCocaFile
(
"todos.json"
,
string
(
cModel
))
c
md_util
.
WriteToCocaFile
(
"todos.json"
,
string
(
cModel
))
table
:=
tablewriter
.
NewWriter
(
os
.
Stdout
)
table
.
SetHeader
([]
string
{
"Date"
,
"Author"
,
"Messages"
,
"FileName"
,
"Line"
})
...
...
core/
infrastructure
/coca_file/file_analysis_helper.go
→
core/
adapter
/coca_file/file_analysis_helper.go
浏览文件 @
8c05762f
文件已移动
core/context/analysis/java_full_app.go
浏览文件 @
8c05762f
...
...
@@ -3,9 +3,9 @@ package analysis
import
(
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/core/adapter/coca_file"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/ast/full"
"github.com/phodal/coca/core/infrastructure/coca_file"
"path/filepath"
)
...
...
core/context/analysis/java_identifier_app.go
浏览文件 @
8c05762f
...
...
@@ -2,9 +2,9 @@ package analysis
import
(
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/core/adapter/coca_file"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/ast/identifier"
"github.com/phodal/coca/core/infrastructure/coca_file"
)
...
...
core/context/api/java_api_app.go
浏览文件 @
8c05762f
...
...
@@ -3,9 +3,9 @@ package api
import
(
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/core/adapter/coca_file"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/ast/api"
"github.com/phodal/coca/core/infrastructure/coca_file"
"path/filepath"
)
...
...
core/context/arch/arch_app_test.go
浏览文件 @
8c05762f
...
...
@@ -3,10 +3,10 @@ package arch
import
(
"encoding/json"
.
"github.com/onsi/gomega"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/core/context/analysis"
"github.com/phodal/coca/core/context/arch/tequila"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/coca_file"
"io"
"path/filepath"
"reflect"
...
...
@@ -48,7 +48,7 @@ func TestConceptAnalyser_Analysis(t *testing.T) {
g
.
Expect
(
len
(
graph
.
SubGraphs
.
SubGraphs
))
.
To
(
Equal
(
3
))
jsonContent
,
_
:=
json
.
MarshalIndent
(
results
,
""
,
"
\t
"
)
content
:=
c
oca_file
.
ReadFile
(
filepath
.
FromSlash
(
codePath
+
"/"
+
"results.json"
))
content
:=
c
md_util
.
ReadFile
(
filepath
.
FromSlash
(
codePath
+
"/"
+
"results.json"
))
g
.
Expect
(
JSONBytesEqual
(
jsonContent
,
content
))
.
To
(
Equal
(
true
))
}
...
...
core/context/bs/bad_smell_app.go
浏览文件 @
8c05762f
...
...
@@ -4,9 +4,10 @@ import (
"encoding/json"
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/core/adapter/coca_file"
"github.com/phodal/coca/core/domain/bs_domain"
"github.com/phodal/coca/core/infrastructure/ast/bs"
"github.com/phodal/coca/core/infrastructure/coca_file"
"path/filepath"
)
...
...
@@ -42,7 +43,7 @@ func (j *BadSmellApp) AnalysisPath(codeDir string, ignoreRules []string) []bs_do
}
bsModel
,
_
:=
json
.
MarshalIndent
(
nodeInfos
,
""
,
"
\t
"
)
c
oca_file
.
WriteToCocaFile
(
"nodeInfos.json"
,
string
(
bsModel
))
c
md_util
.
WriteToCocaFile
(
"nodeInfos.json"
,
string
(
bsModel
))
bsList
:=
AnalysisBadSmell
(
nodeInfos
)
...
...
core/context/call/call_graph_test.go
浏览文件 @
8c05762f
...
...
@@ -3,9 +3,9 @@ package call_test
import
(
"encoding/json"
.
"github.com/onsi/gomega"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/core/context/call"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/coca_file"
"path/filepath"
"testing"
)
...
...
@@ -19,7 +19,7 @@ func Test_should_generate_correct_files(t *testing.T) {
codePath
:=
"../../../_fixtures/call/call_api_test.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
c
oca_file
.
ReadFile
(
codePath
)
file
:=
c
md_util
.
ReadFile
(
codePath
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
dotContent
:=
analyser
.
Analysis
(
"com.phodal.pholedge.book.BookController.createBook"
,
*&
parsedDeps
)
...
...
core/context/concept/concept_analyser_test.go
浏览文件 @
8c05762f
...
...
@@ -2,8 +2,8 @@ package concept
import
(
"encoding/json"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/coca_file"
"log"
"path/filepath"
"testing"
...
...
@@ -19,7 +19,7 @@ func TestConceptAnalyser_Analysis(t *testing.T) {
codePath
:=
"../../../_fixtures/call/call_api_test.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
c
oca_file
.
ReadFile
(
codePath
)
file
:=
c
md_util
.
ReadFile
(
codePath
)
if
file
==
nil
{
log
.
Fatal
(
"lost file"
)
}
...
...
core/context/count/count_app_test.go
浏览文件 @
8c05762f
...
...
@@ -3,8 +3,8 @@ package count
import
(
"encoding/json"
.
"github.com/onsi/gomega"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/coca_file"
"path/filepath"
"testing"
)
...
...
@@ -14,7 +14,7 @@ func TestBuildCallMap(t *testing.T) {
var
parsedDeps
[]
domain
.
JClassNode
codePath
:=
"../../../_fixtures/count/call.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
c
oca_file
.
ReadFile
(
codePath
)
file
:=
c
md_util
.
ReadFile
(
codePath
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
callMap
:=
BuildCallMap
(
parsedDeps
)
...
...
core/context/evaluate/analyser_test.go
浏览文件 @
8c05762f
...
...
@@ -3,10 +3,10 @@ package evaluate
import
(
"encoding/json"
.
"github.com/onsi/gomega"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/core/context/analysis"
"github.com/phodal/coca/core/context/evaluate/evaluator"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/coca_file"
"path/filepath"
"testing"
)
...
...
@@ -18,7 +18,7 @@ func TestAnalyser_Analysis(t *testing.T) {
analyser
:=
NewEvaluateAnalyser
()
codePath
:=
"../../../_fixtures/evaluate/service.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
c
oca_file
.
ReadFile
(
codePath
)
file
:=
c
md_util
.
ReadFile
(
codePath
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
analyser
.
Analysis
(
parsedDeps
,
nil
)
...
...
@@ -33,7 +33,7 @@ func Test_Service_LifeCycle(t *testing.T) {
analyser
:=
NewEvaluateAnalyser
()
codePath
:=
"../../../_fixtures/evaluate/service_lifecycle.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
c
oca_file
.
ReadFile
(
codePath
)
file
:=
c
md_util
.
ReadFile
(
codePath
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
result
:=
analyser
.
Analysis
(
parsedDeps
,
nil
)
...
...
@@ -50,7 +50,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
:=
c
oca_file
.
ReadFile
(
codePath
)
file
:=
c
md_util
.
ReadFile
(
codePath
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
results
:=
analyser
.
Analysis
(
parsedDeps
,
nil
)
...
...
@@ -65,7 +65,7 @@ func Test_Long_Parameters(t *testing.T) {
analyser
:=
NewEvaluateAnalyser
()
codePath
:=
"../../../_fixtures/evaluate/service_long_parameters.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
c
oca_file
.
ReadFile
(
codePath
)
file
:=
c
md_util
.
ReadFile
(
codePath
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
result
:=
analyser
.
Analysis
(
parsedDeps
,
nil
)
...
...
core/context/rcall/rcall_graph.go
浏览文件 @
8c05762f
...
...
@@ -2,9 +2,9 @@ package rcall
import
(
"encoding/json"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/core/context/call"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/coca_file"
)
type
RCallGraph
struct
{
...
...
@@ -19,7 +19,7 @@ func (c RCallGraph) Analysis(funcName string, clzs []domain.JClassNode) string {
rcallMap
:=
BuildRCallMethodMap
(
clzs
,
projectMethodMap
)
mapJson
,
_
:=
json
.
MarshalIndent
(
rcallMap
,
""
,
"
\t
"
)
c
oca_file
.
WriteToCocaFile
(
"rcallmap.json"
,
string
(
mapJson
))
c
md_util
.
WriteToCocaFile
(
"rcallmap.json"
,
string
(
mapJson
))
chain
:=
c
.
buildRCallChain
(
funcName
,
rcallMap
)
...
...
core/context/rcall/rcall_graph_test.go
浏览文件 @
8c05762f
...
...
@@ -2,8 +2,8 @@ package rcall
import
(
"encoding/json"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/coca_file"
"log"
"testing"
...
...
@@ -15,7 +15,7 @@ func TestRCallGraph_Analysis(t *testing.T) {
var
parsedDeps
[]
domain
.
JClassNode
analyser
:=
NewRCallGraph
()
file
:=
c
oca_file
.
ReadFile
(
"../../../_fixtures/call/call_api_test.json"
)
file
:=
c
md_util
.
ReadFile
(
"../../../_fixtures/call/call_api_test.json"
)
if
file
==
nil
{
log
.
Fatal
(
"lost file"
)
}
...
...
core/context/refactor/move_class/move_class_app.go
浏览文件 @
8c05762f
...
...
@@ -4,9 +4,9 @@ import (
"bufio"
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/core/adapter/coca_file"
base2
"github.com/phodal/coca/core/context/refactor/base"
models2
"github.com/phodal/coca/core/context/refactor/base/models"
"github.com/phodal/coca/core/infrastructure/coca_file"
"io"
"io/ioutil"
"log"
...
...
core/context/refactor/rename/rename_method.go
浏览文件 @
8c05762f
package
unused
import
(
"github.com/phodal/coca/cmd/cmd_util"
support3
"github.com/phodal/coca/core/context/refactor/rename/support"
.
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/coca_file"
"io/ioutil"
"log"
"strings"
...
...
@@ -25,7 +25,7 @@ func RenameMethodApp(deps []JClassNode, p string) *RemoveMethodApp {
}
func
(
j
*
RemoveMethodApp
)
Start
()
{
configBytes
:=
c
oca_file
.
ReadFile
(
configPath
)
configBytes
:=
c
md_util
.
ReadFile
(
configPath
)
if
configBytes
==
nil
{
return
}
...
...
core/context/refactor/unused/remove_unused_import.go
浏览文件 @
8c05762f
...
...
@@ -3,9 +3,9 @@ package unused
import
(
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/core/adapter/coca_file"
base2
"github.com/phodal/coca/core/context/refactor/base"
models2
"github.com/phodal/coca/core/context/refactor/base/models"
"github.com/phodal/coca/core/infrastructure/coca_file"
"io/ioutil"
"os"
"path/filepath"
...
...
core/context/refactor/unused_classes/unused_classes_app_test.go
浏览文件 @
8c05762f
...
...
@@ -3,8 +3,8 @@ package unused_classes
import
(
"encoding/json"
.
"github.com/onsi/gomega"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/coca_file"
"path/filepath"
"testing"
)
...
...
@@ -16,7 +16,7 @@ func TestRefactoring(t *testing.T) {
var
parsedDeps
[]
domain
.
JClassNode
codePath
:=
"../../../../_fixtures/count/call.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
c
oca_file
.
ReadFile
(
codePath
)
file
:=
c
md_util
.
ReadFile
(
codePath
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
results
:=
Refactoring
(
parsedDeps
)
...
...
core/context/suggest/suggest_app_test.go
浏览文件 @
8c05762f
...
...
@@ -2,8 +2,8 @@ package suggest
import
(
"encoding/json"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/coca_file"
"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
:=
c
oca_file
.
ReadFile
(
codePath
)
file
:=
c
md_util
.
ReadFile
(
codePath
)
if
file
==
nil
{
log
.
Fatal
(
"lost file"
)
}
...
...
core/context/tbs/tbs_app_test.go
浏览文件 @
8c05762f
...
...
@@ -2,10 +2,10 @@ package tbs
import
(
.
"github.com/onsi/gomega"
"github.com/phodal/coca/core/adapter/coca_file"
"github.com/phodal/coca/core/context/analysis"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/ast"
"github.com/phodal/coca/core/infrastructure/coca_file"
"path/filepath"
"testing"
)
...
...
core/context/todo/todo_app.go
浏览文件 @
8c05762f
...
...
@@ -3,10 +3,10 @@ package todo
import
(
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/core/adapter/coca_file"
"github.com/phodal/coca/core/adapter/shell"
"github.com/phodal/coca/core/context/git"
"github.com/phodal/coca/core/context/todo/astitodo"
"github.com/phodal/coca/core/infrastructure/coca_file"
.
"github.com/phodal/coca/languages/java"
"path/filepath"
"strconv"
...
...
core/infrastructure/ast/ident_helper.go
浏览文件 @
8c05762f
...
...
@@ -2,21 +2,21 @@ package ast
import
(
"encoding/json"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/core/context/analysis"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/coca_file"
)
func
LoadIdentify
(
importPath
string
)
[]
domain
.
JIdentifier
{
var
identifiers
[]
domain
.
JIdentifier
apiContent
:=
c
oca_file
.
ReadCocaFile
(
"identify.json"
)
apiContent
:=
c
md_util
.
ReadCocaFile
(
"identify.json"
)
if
apiContent
==
nil
||
string
(
apiContent
)
==
"null"
{
identifierApp
:=
new
(
analysis
.
JavaIdentifierApp
)
ident
:=
identifierApp
.
AnalysisPath
(
importPath
)
identModel
,
_
:=
json
.
MarshalIndent
(
ident
,
""
,
"
\t
"
)
c
oca_file
.
WriteToCocaFile
(
"identify.json"
,
string
(
identModel
))
c
md_util
.
WriteToCocaFile
(
"identify.json"
,
string
(
identModel
))
return
*&
ident
}
...
...
@@ -28,14 +28,14 @@ func LoadIdentify(importPath string) []domain.JIdentifier {
func
LoadTestIdentify
(
files
[]
string
)
[]
domain
.
JIdentifier
{
var
identifiers
[]
domain
.
JIdentifier
apiContent
:=
c
oca_file
.
ReadCocaFile
(
"tidentify.json"
)
apiContent
:=
c
md_util
.
ReadCocaFile
(
"tidentify.json"
)
if
apiContent
==
nil
||
string
(
apiContent
)
==
"null"
{
identifierApp
:=
analysis
.
NewJavaIdentifierApp
()
ident
:=
identifierApp
.
AnalysisFiles
(
files
)
identModel
,
_
:=
json
.
MarshalIndent
(
ident
,
""
,
"
\t
"
)
c
oca_file
.
WriteToCocaFile
(
"tidentify.json"
,
string
(
identModel
))
c
md_util
.
WriteToCocaFile
(
"tidentify.json"
,
string
(
identModel
))
return
*&
ident
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录