Skip to content

Commit

Permalink
Make "--exclude-dir" support multi-level dirs
Browse files Browse the repository at this point in the history
Fix #564.

Upgrade modules.
  • Loading branch information
apocelipes committed Jan 14, 2025
1 parent 6d92d43 commit 0e298bb
Show file tree
Hide file tree
Showing 15 changed files with 329 additions and 234 deletions.
1 change: 1 addition & 0 deletions examples/issue564/a/level1/level2/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("test for issue 564")
1 change: 1 addition & 0 deletions examples/issue564/b/c/level2/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("test for issue 564")
1 change: 1 addition & 0 deletions examples/issue564/level1/level2/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("test for issue 564")
3 changes: 3 additions & 0 deletions examples/issue564/level1/test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package main

func main() {}
3 changes: 3 additions & 0 deletions examples/issue564/test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package main

func main() {}
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module github.com/boyter/scc/v3
go 1.22

require (
github.com/boyter/gocodewalker v1.3.5
github.com/boyter/gocodewalker v1.4.0
github.com/json-iterator/go v1.1.12
github.com/mattn/go-runewidth v0.0.15
github.com/mattn/go-runewidth v0.0.16
github.com/rs/zerolog v1.30.0
github.com/spf13/cobra v1.8.1
golang.org/x/crypto v0.31.0
golang.org/x/crypto v0.32.0
golang.org/x/text v0.21.0
gopkg.in/yaml.v2 v2.4.0
)
Expand All @@ -23,5 +23,5 @@ require (
github.com/rivo/uniseg v0.4.7 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/sys v0.29.0 // indirect
)
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/boyter/gocodewalker v1.3.5 h1:0FIqU/EGscYzDG9o9770CRhb0esbaDeiaBEYZ4dSCpg=
github.com/boyter/gocodewalker v1.3.5/go.mod h1:hXG8xzR1uURS+99P5/3xh3uWHjaV2XfoMMmvPyhrCDg=
github.com/boyter/gocodewalker v1.4.0 h1:fVmFeQxKpj5tlpjPcyTtJ96btgaHYd9yn6m+T/66et4=
github.com/boyter/gocodewalker v1.4.0/go.mod h1:hXG8xzR1uURS+99P5/3xh3uWHjaV2XfoMMmvPyhrCDg=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
Expand All @@ -20,8 +20,8 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand All @@ -44,16 +44,16 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
Expand Down
53 changes: 53 additions & 0 deletions test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,59 @@ else
echo -e "${GREEN}PASSED Issue379 Regression Check"
fi

# Regression tests for https://github.com/boyter/scc/issues/564
Issue564GoCount=$(./scc -f csv "examples/issue564/" --no-scc-ignore | grep 'Go' | cut -d ',' -f 8)
Issue564PyCount=$(./scc -f csv "examples/issue564/" --no-scc-ignore | grep 'Python' | cut -d ',' -f 8)
Issue564GoExcludeCount=$(./scc -f csv "examples/issue564/" --no-scc-ignore --exclude-dir=level2 | grep 'Go' | cut -d ',' -f 8)
Issue564PyExcludeCount=$(./scc -f csv "examples/issue564/" --no-scc-ignore --exclude-dir=level2 | grep 'Python' | cut -d ',' -f 8)
Issue564GoExclude2Count=$(./scc -f csv "examples/issue564/" --no-scc-ignore --exclude-dir=level1 | grep 'Go' | cut -d ',' -f 8)
Issue564PyExclude2Count=$(./scc -f csv "examples/issue564/" --no-scc-ignore --exclude-dir=level1 | grep 'Python' | cut -d ',' -f 8)
Issue564GoExcludeMultiCount=$(./scc -f csv "examples/issue564/" --no-scc-ignore --exclude-dir=level1/level2 | grep 'Go' | cut -d ',' -f 8)
Issue564PyExcludeMultiCount=$(./scc -f csv "examples/issue564/" --no-scc-ignore --exclude-dir=level1/level2 | grep 'Python' | cut -d ',' -f 8)
if [ $Issue564GoCount -ne 2 ] ; then
echo -e "${RED}======================================================="
echo -e "FAILED Issue564 Go file counting"
echo -e "=======================================================${NC}"
exit
elif [ $Issue564PyCount -ne 3 ] ; then
echo -e "${RED}======================================================="
echo -e "FAILED Issue564 Python file counting"
echo -e "=======================================================${NC}"
exit
elif [ "$Issue564PyExcludeCount" != "" ] ; then
echo -e "${RED}======================================================="
echo -e "FAILED Issue564 exclude level2 Python file counting"
echo -e "=======================================================${NC}"
exit
elif [ $Issue564GoExcludeCount -ne 2 ] ; then
echo -e "${RED}======================================================="
echo -e "FAILED Issue564 exclude level2 Go file counting"
echo -e "=======================================================${NC}"
exit
elif [ $Issue564PyExclude2Count -ne 1 ] ; then
echo -e "${RED}======================================================="
echo -e "FAILED Issue564 exclude level1 Python file counting"
echo -e "=======================================================${NC}"
exit
elif [ $Issue564GoExclude2Count -ne 1 ] ; then
echo -e "${RED}======================================================="
echo -e "FAILED Issue564 exclude level1 Go file counting"
echo -e "=======================================================${NC}"
exit
elif [ $Issue564GoExcludeMultiCount -ne 2 ] ; then
echo -e "${RED}======================================================="
echo -e "FAILED Issue564 exclude level1/level2 Go file counting"
echo -e "=======================================================${NC}"
exit
elif [ $Issue564PyExcludeMultiCount -ne 1 ] ; then
echo -e "${RED}======================================================="
echo -e "FAILED Issue564 exclude level1/level2 Python file counting"
echo -e "=======================================================${NC}"
exit
else
echo -e "${GREEN}PASSED Issue564 Regression Check"
fi

# Extra case for longer languages that are normally truncated
for i in 'CloudFormation (YAM' 'CloudFormation (JSO'
do
Expand Down
32 changes: 32 additions & 0 deletions vendor/github.com/boyter/gocodewalker/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 0 additions & 61 deletions vendor/github.com/boyter/gocodewalker/check.sh

This file was deleted.

30 changes: 30 additions & 0 deletions vendor/github.com/boyter/gocodewalker/dir_suffix.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion vendor/github.com/boyter/gocodewalker/file.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0e298bb

Please sign in to comment.