Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
5ef713b5
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,发现更多精彩内容 >>
未验证
提交
5ef713b5
编写于
1月 08, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: extract get files filter
上级
95a7b8f1
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
30 addition
and
32 deletion
+30
-32
core/adapter/cocafile/file_analysis_helper.go
core/adapter/cocafile/file_analysis_helper.go
+17
-31
core/context/deps/dep_app.go
core/context/deps/dep_app.go
+0
-1
core/context/deps/dep_app_test.go
core/context/deps/dep_app_test.go
+13
-0
未找到文件。
core/adapter/cocafile/file_analysis_helper.go
浏览文件 @
5ef713b5
...
...
@@ -10,44 +10,26 @@ import (
"strings"
)
func
GetJavaFiles
(
codeDir
string
)
[]
string
{
files
:=
make
([]
string
,
0
)
gitIgnore
,
err
:=
ignore
.
CompileIgnoreFile
(
".gitignore"
)
if
err
!=
nil
{
//fmt.Println(err)
}
fi
,
err
:=
os
.
Stat
(
codeDir
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
nil
}
if
fi
.
Mode
()
.
IsRegular
()
{
files
=
append
(
files
,
codeDir
)
return
files
}
var
javaCodeFileFilter
=
func
(
path
string
)
bool
{
return
strings
.
HasSuffix
(
path
,
".java"
)
&&
!
strings
.
Contains
(
path
,
"Test.java"
)
&&
!
strings
.
Contains
(
path
,
"Tests.java"
)
}
_
=
filepath
.
Walk
(
codeDir
,
func
(
path
string
,
fi
os
.
FileInfo
,
err
error
)
error
{
if
gitIgnore
!=
nil
{
if
gitIgnore
.
MatchesPath
(
path
)
{
return
nil
}
var
javaTestFileFilter
=
func
(
path
string
)
bool
{
if
strings
.
Contains
(
path
,
"Test.java"
)
||
strings
.
Contains
(
path
,
"Tests.java"
)
{
return
true
}
return
false
}
if
strings
.
HasSuffix
(
path
,
".java"
)
&&
!
strings
.
Contains
(
path
,
"Test.java"
)
&&
!
strings
.
Contains
(
path
,
"Tests.java"
)
{
files
=
append
(
files
,
path
)
}
return
nil
})
return
files
func
GetJavaFiles
(
codeDir
string
)
[]
string
{
return
GetFilesWithFilter
(
codeDir
,
javaCodeFileFilter
)
}
func
Get
JavaTestFiles
(
codeDir
string
)
[]
string
{
func
Get
FilesWithFilter
(
codeDir
string
,
filter
func
(
path
string
)
bool
)
[]
string
{
files
:=
make
([]
string
,
0
)
gitIgnore
,
err
:=
ignore
.
CompileIgnoreFile
(
".gitignore"
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
//
fmt.Println(err)
}
fi
,
err
:=
os
.
Stat
(
codeDir
)
...
...
@@ -68,7 +50,7 @@ func GetJavaTestFiles(codeDir string) []string {
}
}
if
strings
.
Contains
(
path
,
"Test.java"
)
||
strings
.
Contains
(
path
,
"Tests.java"
)
{
if
filter
(
path
)
{
files
=
append
(
files
,
path
)
}
return
nil
...
...
@@ -76,6 +58,10 @@ func GetJavaTestFiles(codeDir string) []string {
return
files
}
func
GetJavaTestFiles
(
codeDir
string
)
[]
string
{
return
GetFilesWithFilter
(
codeDir
,
javaTestFileFilter
)
}
func
ProcessFile
(
path
string
)
*
JavaParser
{
is
,
_
:=
antlr
.
NewFileStream
(
path
)
lexer
:=
NewJavaLexer
(
is
)
...
...
core/context/deps/dep_app.go
浏览文件 @
5ef713b5
...
...
@@ -21,4 +21,3 @@ func (d *DepApp) BuildImportMap(deps []domain.JClassNode) map[string]domain.JImp
return
impMap
}
core/context/deps/dep_app_test.go
浏览文件 @
5ef713b5
...
...
@@ -78,3 +78,16 @@ func Test_ShouldCountDeps_WhenHadClassNodes(t *testing.T) {
g
.
Expect
(
len
(
importMap
))
.
To
(
Equal
(
25
))
}
//func Test_ListUnusedImportForOneGradleFile(t *testing.T) {
// g := NewGomegaWithT(t)
//
// codePath := "../../../_fixtures/deps/maven_sample/"
// classNodes, _, _ := cocatest.BuildAnalysisDeps(codePath)
//
// depApp := NewDepApp()
// importMap := depApp.BuildImportMap(classNodes)
//
// fmt.Println(importMap)
// g.Expect(len(importMap)).To(Equal(2))
//}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录