Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
d00f04b7
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,发现更多精彩内容 >>
未验证
提交
d00f04b7
编写于
12月 18, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: move bs to adapter
上级
6e3235ac
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
25 addition
and
25 deletion
+25
-25
cmd/bs.go
cmd/bs.go
+1
-1
core/adapter/bs/BadSmellApp.go
core/adapter/bs/BadSmellApp.go
+5
-5
core/adapter/bs/BadSmellListener.go
core/adapter/bs/BadSmellListener.go
+19
-19
core/adapter/bs/models/BsModel.go
core/adapter/bs/models/BsModel.go
+0
-0
未找到文件。
cmd/bs.go
浏览文件 @
d00f04b7
package
cmd
import
(
"coca/core/
domain
/bs"
"coca/core/
adapter
/bs"
"coca/core/support"
"encoding/json"
"github.com/spf13/cobra"
...
...
core/
domain
/bs/BadSmellApp.go
→
core/
adapter
/bs/BadSmellApp.go
浏览文件 @
d00f04b7
package
bs
import
(
"coca/core/domain
/bs/models"
models2
"coca/core/adapter
/bs/models"
"coca/core/support"
"encoding/json"
"fmt"
...
...
@@ -14,7 +14,7 @@ import (
.
"coca/core/languages/java"
)
var
nodeInfos
[]
models
.
JFullClassNode
var
nodeInfos
[]
models
2
.
JFullClassNode
type
BadSmellModel
struct
{
File
string
`json:"File,omitempty"`
...
...
@@ -30,7 +30,7 @@ func (j *BadSmellApp) AnalysisPath(codeDir string, ignoreRules []string) []BadSm
nodeInfos
=
nil
files
:=
(
*
BadSmellApp
)(
nil
)
.
javaFiles
(
codeDir
)
for
index
:=
range
files
{
nodeInfo
:=
models
.
NewJFullClassNode
()
nodeInfo
:=
models
2
.
NewJFullClassNode
()
file
:=
files
[
index
]
displayName
:=
filepath
.
Base
(
file
)
...
...
@@ -72,7 +72,7 @@ func filterBadsmellList(models []BadSmellModel, ignoreRules map[string]bool) []B
return
results
}
func
analysisBadSmell
(
nodes
[]
models
.
JFullClassNode
)
[]
BadSmellModel
{
func
analysisBadSmell
(
nodes
[]
models
2
.
JFullClassNode
)
[]
BadSmellModel
{
var
badSmellList
[]
BadSmellModel
for
_
,
node
:=
range
nodes
{
// To be Defined number
...
...
@@ -140,7 +140,7 @@ func analysisBadSmell(nodes []models.JFullClassNode) []BadSmellModel {
return
badSmellList
}
func
withOutGetterSetterClass
(
fullMethods
[]
models
.
JFullMethod
)
int
{
func
withOutGetterSetterClass
(
fullMethods
[]
models
2
.
JFullMethod
)
int
{
var
normalMethodSize
=
0
for
_
,
method
:=
range
fullMethods
{
if
!
strings
.
Contains
(
method
.
Name
,
"get"
)
&&
!
strings
.
Contains
(
method
.
Name
,
"set"
)
{
...
...
core/
domain
/bs/BadSmellListener.go
→
core/
adapter
/bs/BadSmellListener.go
浏览文件 @
d00f04b7
package
bs
import
(
"coca/core/domain
/bs/models"
models2
"coca/core/adapter
/bs/models"
.
"coca/core/languages/java"
"github.com/antlr/antlr4/runtime/Go/antlr"
"reflect"
...
...
@@ -17,13 +17,13 @@ var currentClzType string
var
currentClzExtends
string
var
currentClzImplements
[]
string
var
methods
[]
models
.
JFullMethod
var
methodCalls
[]
models
.
JFullMethodCall
var
methods
[]
models
2
.
JFullMethod
var
methodCalls
[]
models
2
.
JFullMethodCall
var
fields
=
make
(
map
[
string
]
string
)
var
localVars
=
make
(
map
[
string
]
string
)
var
formalParameters
=
make
(
map
[
string
]
string
)
var
currentClassBs
models
.
ClassBadSmellInfo
var
currentClassBs
models
2
.
ClassBadSmellInfo
func
NewBadSmellListener
()
*
BadSmellListener
{
currentClz
=
""
...
...
@@ -39,8 +39,8 @@ type BadSmellListener struct {
BaseJavaParserListener
}
func
(
s
*
BadSmellListener
)
getNodeInfo
()
*
models
.
JFullClassNode
{
return
&
models
.
JFullClassNode
{
func
(
s
*
BadSmellListener
)
getNodeInfo
()
*
models
2
.
JFullClassNode
{
return
&
models
2
.
JFullClassNode
{
currentPkg
,
currentClz
,
currentClzType
,
...
...
@@ -105,7 +105,7 @@ func (s *BadSmellListener) EnterInterfaceMethodDeclaration(ctx *InterfaceMethodD
typeType
:=
ctx
.
TypeTypeOrVoid
()
.
GetText
()
var
methodParams
[]
models
.
JFullParameter
=
nil
var
methodParams
[]
models
2
.
JFullParameter
=
nil
parameters
:=
ctx
.
FormalParameters
()
if
parameters
!=
nil
{
if
reflect
.
TypeOf
(
parameters
.
GetChild
(
1
))
.
String
()
==
"*parser.FormalParameterListContext"
{
...
...
@@ -115,14 +115,14 @@ func (s *BadSmellListener) EnterInterfaceMethodDeclaration(ctx *InterfaceMethodD
paramContext
:=
param
.
(
*
FormalParameterContext
)
paramType
:=
paramContext
.
TypeType
()
.
GetText
()
paramValue
:=
paramContext
.
VariableDeclaratorId
()
.
(
*
VariableDeclaratorIdContext
)
.
IDENTIFIER
()
.
GetText
()
methodParams
=
append
(
methodParams
,
*&
models
.
JFullParameter
{
paramType
,
paramValue
})
methodParams
=
append
(
methodParams
,
*&
models
2
.
JFullParameter
{
paramType
,
paramValue
})
}
}
}
methodBSInfo
:=
*&
models
.
MethodBadSmellInfo
{
0
,
0
}
methodBSInfo
:=
*&
models
2
.
MethodBadSmellInfo
{
0
,
0
}
method
:=
&
models
.
JFullMethod
{
method
:=
&
models
2
.
JFullMethod
{
name
,
typeType
,
startLine
,
...
...
@@ -168,7 +168,7 @@ func (s *BadSmellListener) EnterMethodDeclaration(ctx *MethodDeclarationContext)
typeType
:=
ctx
.
TypeTypeOrVoid
()
.
GetText
()
methodBody
:=
ctx
.
MethodBody
()
.
GetText
()
var
methodParams
[]
models
.
JFullParameter
=
nil
var
methodParams
[]
models
2
.
JFullParameter
=
nil
parameters
:=
ctx
.
FormalParameters
()
if
parameters
!=
nil
{
if
reflect
.
TypeOf
(
parameters
.
GetChild
(
1
))
.
String
()
==
"*parser.FormalParameterListContext"
{
...
...
@@ -178,17 +178,17 @@ func (s *BadSmellListener) EnterMethodDeclaration(ctx *MethodDeclarationContext)
paramContext
:=
param
.
(
*
FormalParameterContext
)
paramType
:=
paramContext
.
TypeType
()
.
GetText
()
paramValue
:=
paramContext
.
VariableDeclaratorId
()
.
(
*
VariableDeclaratorIdContext
)
.
IDENTIFIER
()
.
GetText
()
methodParams
=
append
(
methodParams
,
*&
models
.
JFullParameter
{
paramType
,
paramValue
})
methodParams
=
append
(
methodParams
,
*&
models
2
.
JFullParameter
{
paramType
,
paramValue
})
localVars
[
paramValue
]
=
paramType
}
}
}
methodBSInfo
:=
*&
models
.
MethodBadSmellInfo
{
0
,
0
}
methodBSInfo
:=
*&
models
2
.
MethodBadSmellInfo
{
0
,
0
}
methodBadSmellInfo
:=
buildMethodBSInfo
(
ctx
,
methodBSInfo
)
method
:=
&
models
.
JFullMethod
{
method
:=
&
models
2
.
JFullMethod
{
name
,
typeType
,
startLine
,
...
...
@@ -202,7 +202,7 @@ func (s *BadSmellListener) EnterMethodDeclaration(ctx *MethodDeclarationContext)
methods
=
append
(
methods
,
*
method
)
}
func
buildMethodBSInfo
(
context
*
MethodDeclarationContext
,
bsInfo
models
.
MethodBadSmellInfo
)
models
.
MethodBadSmellInfo
{
func
buildMethodBSInfo
(
context
*
MethodDeclarationContext
,
bsInfo
models
2
.
MethodBadSmellInfo
)
models2
.
MethodBadSmellInfo
{
methodBody
:=
context
.
MethodBody
()
blockContext
:=
methodBody
.
GetChild
(
0
)
if
reflect
.
TypeOf
(
blockContext
)
.
String
()
==
"*parser.BlockContext"
{
...
...
@@ -275,16 +275,16 @@ func (s *BadSmellListener) EnterMethodCall(ctx *MethodCallContext) {
targetType
=
currentClzExtends
}
if
fullType
!=
""
{
jMethodCall
:=
&
models
.
JFullMethodCall
{
removeTarget
(
fullType
),
""
,
targetType
,
callee
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
jMethodCall
:=
&
models
2
.
JFullMethodCall
{
removeTarget
(
fullType
),
""
,
targetType
,
callee
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
methodCalls
=
append
(
methodCalls
,
*
jMethodCall
)
}
else
{
if
ctx
.
GetText
()
==
targetType
{
methodName
:=
ctx
.
IDENTIFIER
()
.
GetText
()
jMethodCall
:=
&
models
.
JFullMethodCall
{
currentPkg
,
""
,
currentClz
,
methodName
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
jMethodCall
:=
&
models
2
.
JFullMethodCall
{
currentPkg
,
""
,
currentClz
,
methodName
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
methodCalls
=
append
(
methodCalls
,
*
jMethodCall
)
}
else
{
methodName
:=
ctx
.
IDENTIFIER
()
.
GetText
()
jMethodCall
:=
&
models
.
JFullMethodCall
{
currentPkg
,
"NEEDFIX"
,
targetType
,
methodName
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
jMethodCall
:=
&
models
2
.
JFullMethodCall
{
currentPkg
,
"NEEDFIX"
,
targetType
,
methodName
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
methodCalls
=
append
(
methodCalls
,
*
jMethodCall
)
}
}
...
...
@@ -303,7 +303,7 @@ func (s *BadSmellListener) EnterExpression(ctx *ExpressionContext) {
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
stopLinePosition
:=
startLinePosition
+
len
(
text
)
jMethodCall
:=
&
models
.
JFullMethodCall
{
removeTarget
(
fullType
),
""
,
targetType
,
methodName
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
jMethodCall
:=
&
models
2
.
JFullMethodCall
{
removeTarget
(
fullType
),
""
,
targetType
,
methodName
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
methodCalls
=
append
(
methodCalls
,
*
jMethodCall
)
}
}
...
...
core/
domain
/bs/models/BsModel.go
→
core/
adapter
/bs/models/BsModel.go
浏览文件 @
d00f04b7
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录