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

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

This file was deleted.

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

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.