Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
cae177e7
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 搜索 >>
未验证
提交
cae177e7
编写于
12月 31, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: [ddd] extract vars
上级
fb0533bb
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
29 addition
and
28 deletion
+29
-28
cmd/api.go
cmd/api.go
+1
-2
cmd/arch.go
cmd/arch.go
+1
-2
cmd/cmd_util/deps_loader.go
cmd/cmd_util/deps_loader.go
+19
-0
cmd/cmd_util/ident_helper.go
cmd/cmd_util/ident_helper.go
+5
-6
cmd/cmd_util/osexec.go
cmd/cmd_util/osexec.go
+0
-14
cmd/tbs.go
cmd/tbs.go
+1
-2
core/context/tbs/tbs_app_test.go
core/context/tbs/tbs_app_test.go
+2
-2
未找到文件。
cmd/api.go
浏览文件 @
cae177e7
...
...
@@ -8,7 +8,6 @@ import (
"github.com/phodal/coca/core/context/api"
"github.com/phodal/coca/core/context/call"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/ast"
"github.com/spf13/cobra"
"log"
"os"
...
...
@@ -31,7 +30,7 @@ var (
apiCmdConfig
ApiCmdConfig
restApis
[]
domain
.
RestApi
identifiers
=
ast
.
LoadIdentify
(
apiCmdConfig
.
DependencePath
)
identifiers
=
cmd_util
.
LoadIdentify
(
apiCmdConfig
.
DependencePath
)
identifiersMap
=
domain
.
BuildIdentifierMap
(
identifiers
)
diMap
=
domain
.
BuildDIMap
(
identifiers
,
identifiersMap
)
)
...
...
cmd/arch.go
浏览文件 @
cae177e7
...
...
@@ -7,7 +7,6 @@ import (
"github.com/phodal/coca/core/context/arch"
"github.com/phodal/coca/core/context/arch/tequila"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/ast"
"github.com/spf13/cobra"
"os"
"strings"
...
...
@@ -27,7 +26,7 @@ var archCmd = &cobra.Command{
Short
:
"project package visualization"
,
Long
:
``
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
identifiers
=
ast
.
LoadIdentify
(
apiCmdConfig
.
DependencePath
)
identifiers
=
cmd_util
.
LoadIdentify
(
apiCmdConfig
.
DependencePath
)
identifiersMap
=
domain
.
BuildIdentifierMap
(
identifiers
)
parsedDeps
:=
cmd_util
.
GetDepsFromJson
(
archCmdConfig
.
DependencePath
)
...
...
cmd/cmd_util/deps_loader.go
0 → 100644
浏览文件 @
cae177e7
package
cmd_util
import
(
"encoding/json"
"github.com/phodal/coca/core/domain"
"log"
)
func
GetDepsFromJson
(
depPath
string
)
[]
domain
.
JClassNode
{
var
parsedDeps
[]
domain
.
JClassNode
file
:=
ReadFile
(
depPath
)
if
file
==
nil
{
log
.
Fatal
(
"lost file:"
+
depPath
)
}
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
return
parsedDeps
}
c
ore/infrastructure/ast
/ident_helper.go
→
c
md/cmd_util
/ident_helper.go
浏览文件 @
cae177e7
package
ast
package
cmd_util
import
(
"encoding/json"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/core/context/analysis"
"github.com/phodal/coca/core/domain"
)
...
...
@@ -10,13 +9,13 @@ import (
func
LoadIdentify
(
importPath
string
)
[]
domain
.
JIdentifier
{
var
identifiers
[]
domain
.
JIdentifier
apiContent
:=
cmd_util
.
ReadCocaFile
(
"identify.json"
)
apiContent
:=
ReadCocaFile
(
"identify.json"
)
if
apiContent
==
nil
||
string
(
apiContent
)
==
"null"
{
identifierApp
:=
new
(
analysis
.
JavaIdentifierApp
)
ident
:=
identifierApp
.
AnalysisPath
(
importPath
)
identModel
,
_
:=
json
.
MarshalIndent
(
ident
,
""
,
"
\t
"
)
cmd_util
.
WriteToCocaFile
(
"identify.json"
,
string
(
identModel
))
WriteToCocaFile
(
"identify.json"
,
string
(
identModel
))
return
*&
ident
}
...
...
@@ -28,14 +27,14 @@ func LoadIdentify(importPath string) []domain.JIdentifier {
func
LoadTestIdentify
(
files
[]
string
)
[]
domain
.
JIdentifier
{
var
identifiers
[]
domain
.
JIdentifier
apiContent
:=
cmd_util
.
ReadCocaFile
(
"tidentify.json"
)
apiContent
:=
ReadCocaFile
(
"tidentify.json"
)
if
apiContent
==
nil
||
string
(
apiContent
)
==
"null"
{
identifierApp
:=
analysis
.
NewJavaIdentifierApp
()
ident
:=
identifierApp
.
AnalysisFiles
(
files
)
identModel
,
_
:=
json
.
MarshalIndent
(
ident
,
""
,
"
\t
"
)
cmd_util
.
WriteToCocaFile
(
"tidentify.json"
,
string
(
identModel
))
WriteToCocaFile
(
"tidentify.json"
,
string
(
identModel
))
return
*&
ident
}
...
...
cmd/cmd_util/
file
.go
→
cmd/cmd_util/
osexec
.go
浏览文件 @
cae177e7
package
cmd_util
import
(
"encoding/json"
"fmt"
"github.com/phodal/coca/cmd/config"
"github.com/phodal/coca/core/domain"
"log"
"os/exec"
)
func
GetDepsFromJson
(
depPath
string
)
[]
domain
.
JClassNode
{
var
parsedDeps
[]
domain
.
JClassNode
file
:=
ReadFile
(
depPath
)
if
file
==
nil
{
log
.
Fatal
(
"lost file:"
+
depPath
)
}
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
return
parsedDeps
}
func
ConvertToSvg
(
name
string
)
{
cmd
:=
exec
.
Command
(
"dot"
,
[]
string
{
"-Tsvg"
,
config
.
CocaConfig
.
ReporterPath
+
"/"
+
name
+
".dot"
,
"-o"
,
config
.
CocaConfig
.
ReporterPath
+
"/"
+
name
+
".svg"
}
...
)
_
,
err
:=
cmd
.
CombinedOutput
()
...
...
cmd/tbs.go
浏览文件 @
cae177e7
...
...
@@ -9,7 +9,6 @@ import (
"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/spf13/cobra"
"os"
"strconv"
...
...
@@ -32,7 +31,7 @@ var tbsCmd = &cobra.Command{
files
:=
coca_file
.
GetJavaTestFiles
(
tbsCmdConfig
.
Path
)
var
identifiers
[]
domain
.
JIdentifier
identifiers
=
ast
.
LoadTestIdentify
(
files
)
identifiers
=
cmd_util
.
LoadTestIdentify
(
files
)
identifiersMap
:=
domain
.
BuildIdentifierMap
(
identifiers
)
var
classes
[]
string
=
nil
...
...
core/context/tbs/tbs_app_test.go
浏览文件 @
cae177e7
...
...
@@ -2,10 +2,10 @@ package tbs
import
(
.
"github.com/onsi/gomega"
"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/domain"
"github.com/phodal/coca/core/infrastructure/ast"
"path/filepath"
"testing"
)
...
...
@@ -115,7 +115,7 @@ func buildTbsResult(codePath string) []TestBadSmell {
files
:=
coca_file
.
GetJavaTestFiles
(
codePath
)
var
identifiers
[]
domain
.
JIdentifier
identifiers
=
ast
.
LoadTestIdentify
(
files
)
identifiers
=
cmd_util
.
LoadTestIdentify
(
files
)
identifiersMap
:=
domain
.
BuildIdentifierMap
(
identifiers
)
var
classes
[]
string
=
nil
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录