Skip to content

Broken symlinks in libraries results in linter panic #680

Closed
@cmaglie

Description

@cmaglie

Describe the problem

If there is a broken symlink in a library the linter panics.

To reproduce

Try to lint this library: eloquent_edgeimpulse.tar.gz

cmaglie:~$ tar xfv eloquent_edgeimpulse.tar.gz 
eloquent_edgeimpulse/
eloquent_edgeimpulse/library.properties
eloquent_edgeimpulse/examples/
eloquent_edgeimpulse/examples/EdgeImpulse_Serial/
eloquent_edgeimpulse/examples/EdgeImpulse_Serial/EdgeImpulse_Serial.ino
eloquent_edgeimpulse/LICENSE
eloquent_edgeimpulse/README.md
eloquent_edgeimpulse/src/
eloquent_edgeimpulse/src/eloquent_edgeimpulse.h
eloquent_edgeimpulse/src/eloquent_edgeimpulse/
eloquent_edgeimpulse/src/eloquent_edgeimpulse/impulse.h
eloquent_edgeimpulse/src/eloquent_edgeimpulse/math.h
eloquent_edgeimpulse/src/eloquent_edgeimpulse/exception.h
eloquent_edgeimpulse/src/eloquent_edgeimpulse/circular_buffer.h

cmaglie:~$ cd eloquent_edgeimpulse/
cmaglie:~/eloquent_edgeimpulse$ ../Software/arduino-lint 
Linting library in /home/cmaglie/eloquent_edgeimpulse
panic: stat /home/cmaglie/eloquent_edgeimpulse/src/eloquent_edgeimpulse/circular_buffer.h: no such file or directory

goroutine 1 [running]:
github.com/arduino/arduino-lint/internal/rule/rulefunction.LibraryContainsSymlinks()
	/home/build/internal/rule/rulefunction/library.go:90 +0x1f6
github.com/arduino/arduino-lint/internal/rule.Runner({0xc0002ff270, 0x1633db8, 0x0})
	/home/build/internal/rule/rule.go:53 +0x24a
github.com/arduino/arduino-lint/internal/command.ArduinoLint(0xc000034900, {0x1633db8, 0x0, 0x0})
	/home/build/internal/command/command.go:77 +0x645
github.com/spf13/cobra.(*Command).execute(0xc000034900, {0xc0000321e0, 0x0, 0x0})
	/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:987 +0xa87
github.com/spf13/cobra.(*Command).ExecuteC(0xc000034900)
	/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x41e
github.com/spf13/cobra.(*Command).Execute(...)
	/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
main.main()
	/home/build/main.go:33 +0x1e

cmaglie:~/eloquent_edgeimpulse$ ls -l /home/cmaglie/eloquent_edgeimpulse/src/eloquent_edgeimpulse/circular_buffer.h
lrwxrwxrwx 1 cmaglie cmaglie 76 gen  9 16:24 /home/cmaglie/eloquent_edgeimpulse/src/eloquent_edgeimpulse/circular_buffer.h -> /Users/simone/Documents/Arduino/libraries/eloquent_commons/circular_buffer.h

Expected behavior

Do not panic, and output an error about broken symlinks.
It should also output an error if the symlink points outside the library.

Arduino Lint version

nightly

Operating system

Linux

Operating system version

Ubuntu 23.02

Additional context

No response

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest version
  • My report contains all necessary details

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions