arduino / arduino-lint

Tool to check for problems with Arduino projects
https://arduino.github.io/arduino-lint/latest/
GNU General Public License v3.0
106 stars 12 forks source link

Library with root `example` file is causing arduino-lint to crash #751

Closed umbynos closed 3 months ago

umbynos commented 3 months ago

Describe the problem

A library with example root file is crashing the tool

To reproduce

This is the culprit: https://github.com/Arathierl/Home-Automation/blob/98ca53400080f2a2f5ca15cb6d6902c817291c26/example

  export ARDUINO_LINT_OFFICIAL="false"

  "/home/runner/work/_temp/arduino-lint/arduino-lint" \
    --compliance=permissive \
    --format=text \
    --library-manager=submit \
    --project-type=library \
    --recursive=false \
    --report-file="/home/runner/work/_temp/report.json" \
    "Home-Automation-using-arduino" > \
      "/home/runner/work/_temp/report.txt"
  shell: /usr/bin/bash -e {0}
  env:
    SUBMISSION_PARSER_VERSION: 1.1.1
    MAINTAINERS: # GitHub user names to request reviews from in cases where PRs can't be managed automatically.
  - per1234

    CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT: check-submissions-failed
    ERROR_MESSAGE_PREFIX: :x: **ERROR:** 
    JSON_REPORT_PATH: /home/runner/work/_temp/report.json
    TEXT_REPORT_PATH: /home/runner/work/_temp/report.txt
    ARDUINO_LINT_INSTALLATION_PATH: /home/runner/work/_temp/arduino-lint
    PASS: true
    FAIL_FLAG_PATH: /home/runner/work/_temp/.check-submissions-failed
panic: readdirent Home-Automation-using-arduino/example: not a directory

goroutine 1 [running]:
github.com/arduino/arduino-lint/internal/project.findSubprojects({0xc0003d8e20, 0x0, 0x8}, 0x1)
    /home/build/internal/project/project.go:199 +0x705
github.com/arduino/arduino-lint/internal/project.findProjects(0xc0003d8e20)
    /home/build/internal/project/project.go:109 +0x38b
github.com/arduino/arduino-lint/internal/project.FindProjects()
    /home/build/internal/project/project.go:47 +0xc9
github.com/arduino/arduino-lint/internal/command.ArduinoLint(0xc0003db900, {0xc0003ee690, 0x1, 0x7})
    /home/build/internal/command/command.go:70 +0xd7
github.com/spf13/cobra.(*Command).execute(0xc0003db900, {0xc0000bc010, 0x7, 0x7})
    /go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:860 +0x5f8
github.com/spf13/cobra.(*Command).ExecuteC(0xc0003db900)
    /go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:974 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
    /go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:902
main.main()
    /home/build/main.go:33 +0x1e
Error: Process completed with exit code 2.

https://github.com/arduino/library-registry/actions/runs/10089139998/job/27896099282#step:8:27

Expected behavior

Arduino-lint should report the problem without crashing

Arduino Lint version

1.2.1

Operating system

Linux

Operating system version

n/a

Additional context

No response

Issue checklist