Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #172 #173

Merged
merged 1 commit into from
May 4, 2020
Merged

Fix #172 #173

merged 1 commit into from
May 4, 2020

Conversation

gallois
Copy link
Contributor

@gallois gallois commented May 4, 2020

In short, symlinks with long paths AND contents that does not end with new lines would break the code. Following the link path gets us to actually read the file size properly and then it works. I'm not sure at all how to test this, suggestions appreciated :)

[11ms][~/go/src/github.com/boyter/scc]$ tree /tmp/foo 
/tmp/foo
├── bar
│   └── baz
│       └── qux
│           └── quux
│               └── quuz
│                   └── grault
│                       └── garply
│                           └── waldo
│                               └── fred
│                                   └── plugh
│                                       └── xyzzy
│                                           └── thud
│                                               └── wibble
│                                                   └── wobble
│                                                       └── wubble
│                                                           └── flob
│                                                               └── foobar.py
└── bolf
    └── elbbuw
        └── elbbow
            └── elbbiw
                └── duht
                    └── yzzyx
                        └── hgulp
                            └── derf
                                └── odlaw
                                    └── ylprag
                                        └── tluarg
                                            └── zuuq
                                                └── xuuq
                                                    └── xuq
                                                        └── zab
                                                            └── rab
                                                                ├── foobar.py -> /tmp/foo/bar/baz/qux/quux/quuz/grault/garply/waldo/fred/plugh/xyzzy/thud/wibble/wobble/wubble/flob/foobar.py
                                                                └── tmpfs
                                                                    └── foobar.py -> /tmp/foo/bar/baz/qux/quux/quuz/grault/garply/waldo/fred/plugh/xyzzy/thud/wibble/wobble/wubble/flob/foobar.py

33 directories, 3 files
[8ms][~/go/src/github.com/boyter/scc]$ # before changes
[~/go/src/github.com/boyter/scc]$ go run main.go /tmp/foo/
panic: runtime error: index out of range [9] with length 9

goroutine 9 [running]:
github.com/boyter/scc/processor.codeState(0xc0003fe0e0, 0x1, 0x6b, 0x2, 0xc00042b348, 0x0, 0x0, 0xc00042b348, 0x0, 0x0, ...)
	/home/gallois/go/src/github.com/boyter/scc/processor/workers.go:195 +0x730
github.com/boyter/scc/processor.CountStats(0xc0003fe0e0)
	/home/gallois/go/src/github.com/boyter/scc/processor/workers.go:432 +0xdca
github.com/boyter/scc/processor.processFile(0xc0003fe0e0, 0xc00041a100)
	/home/gallois/go/src/github.com/boyter/scc/processor/workers.go:708 +0x27c
github.com/boyter/scc/processor.fileProcessorWorker.func1(0xc0000664e0, 0xc000242008, 0xc000242020, 0xc000242028, 0xc000066540, 0xc000242030)
	/home/gallois/go/src/github.com/boyter/scc/processor/workers.go:649 +0x284
created by github.com/boyter/scc/processor.fileProcessorWorker
	/home/gallois/go/src/github.com/boyter/scc/processor/workers.go:625 +0xfb
exit status 2
[442ms][1][~/go/src/github.com/boyter/scc]$ # after changes         
[~/go/src/github.com/boyter/scc]$ go run main.go /tmp/foo/
───────────────────────────────────────────────────────────────────────────────
Language                 Files     Lines   Blanks  Comments     Code Complexity
───────────────────────────────────────────────────────────────────────────────
Python                       3         3        0         0        3          0
───────────────────────────────────────────────────────────────────────────────
Total                        3         3        0         0        3          0
───────────────────────────────────────────────────────────────────────────────
Estimated Cost to Develop $60
Estimated Schedule Effort 0.383061 months
Estimated People Required 0.018744
───────────────────────────────────────────────────────────────────────────────

@boyter
Copy link
Owner

boyter commented May 4, 2020

Neat. Merging in. Ill have a think about how to add some test for it.

@boyter boyter merged commit a41df84 into boyter:master May 4, 2020
@boyter
Copy link
Owner

boyter commented Sep 4, 2020

@gallois Just to let you know, I modified this PR of yours as I found a few edge cases it did not cater for fully. The next release of scc will however give you the ability to turn on following of symlinks.

You can find more details here #193 but I believe the new solution should be better for everything. You will still be getting credit in the release notes though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants