jikan-me / jikan

Unofficial MyAnimeList PHP+REST API which provides functions other than the official API
https://jikan.moe
MIT License
875 stars 93 forks source link

Fix linting in github actions #424

Closed pushrbx closed 2 years ago

pushrbx commented 2 years ago

Currently the linting bit is failing in github actions, because from the decoded json the "results" is an array, but it's treated as an object.

PHP Warning:  Undefined array key "results" in /home/runner/work/jikan/jikan/.github/workflows/utilities/lint-push on line 23
PHP Warning:  Trying to access array offset on value of type null in /home/runner/work/jikan/jikan/.github/workflows/utilities/lint-push on line 23
PHP Fatal error:  Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /home/runner/work/jikan/jikan/.github/workflows/utilities/lint-push:23
Stack trace:
#0 {main}
  thrown in /home/runner/work/jikan/jikan/.github/workflows/utilities/lint-push on line 23
nerg4l commented 2 years ago

I think the error is related to something else.

Output structure of ./vendor/bin/parallel-lint --no-colors --no-progress --json .:

{
  "phpVersion": 80019,
  "hhvmVersion": "",
  "parallelJobs": 10,
  "results": {
    "checkedFiles": [],
    "filesWithSyntaxError": [],
    "skippedFiles": [],
    "errors": []
  }
}

The error message you see there says Undefined array key "results" which means results are missing from the decoded JSON.

If you run ./.github/workflows/utilities/lint-push 97dee621 then inside the script $files will contain [] and the output of parallel-lint will be:

{
  "type": "JakubOnderka\\PhpParallelLint\\NotExistsPathException",
  "message": "Path '' not found",
  "code":0
}

The simplest fix would be to run parallel-lint --no-colors --no-progress --json ./src ./test. I think we can live with that extra 1 second of CI time which is caused by linting all files instead of linting only changed files.