cqfn / pdd

Command line toolkit for collecting TODO markers from your code, known as Puzzle Driven Development (PDD)
https://www.0pdd.com
MIT License
76 stars 25 forks source link

[bug] Doesn't extract puzzles from JS files that has a shebang #214

Closed php-coder closed 1 year ago

php-coder commented 1 year ago

(Initially submitted against 0pdd but it has been discovered that it's a bug in pdd: https://github.com/yegor256/0pdd/issues/395)

pdd doesn't extract puzzles from JS code. Here are the examples:

$ git grep -n @todo
src/cli.js:16:        // @todo #24 Document --dest-dir option
src/cli.js:102:            // @todo #27 Document usage of user defined routes
src/cli.js:118:    // @todo #28 Create db.py with async API
src/cli.js:301:    // @todo #24 [js] Possibly incorrect project name with --dest-dir option

At GitHub: https://github.com/php-coder/query2app/blob/27ffed4faa098b8ba006c51b0a3fc8db5552eb7d/src/cli.js#L16

It's supposed that pdd should find these puzzles and create issues for them but it didn't find puzzles there.

php-coder commented 1 year ago

Hm, perhaps there is no colon after ticket number?!..

php-coder commented 1 year ago

Any updates on this?

php-coder commented 1 year ago

I ran pdd manually and it complain that this is a binary file:

/data/src/cli.js is a binary file (11908 bytes)
php-coder commented 1 year ago

It looks like pdd expects that a file type will contain text/ substring

https://github.com/cqfn/pdd/blob/63948d268b9c82c5e37faae3cd1341d07aad7385/lib/pdd/sources.rb#L90C41-L91

while in this case it doesn't:

$ file src/cli.js
src/cli.js: a /usr/bin/env node script text executable, ASCII text
php-coder commented 1 year ago

Nope, the theory doesn't work:

$ file --mime src/cli.js
src/cli.js: text/plain; charset=us-ascii
php-coder commented 1 year ago

I debugged it and I found that fm.file(file) returns application/javascript; charset=us-ascii for that file:

/data/src/cli.js has MIME type: application/javascript; charset=us-ascii

Most likely, because it has the following shebang:

$ head -1 src/cli.js
#!/usr/bin/env node
php-coder commented 1 year ago

I confirm: removing a shebang, did the trick -- pdd found all the puzzles in this file.

php-coder commented 1 year ago

@yegor256 Hi Egor, I don't see any activity in this repository. Is the project still maintained?

yegor256 commented 1 year ago

@php-coder of course! The latest release was done six month ago. Let me check this bug today.

yegor256 commented 1 year ago

@rultor release, tag is 0.23.2

rultor commented 1 year ago

@rultor release, tag is 0.23.2

@yegor256 OK, I will release it now. Please check the progress here

rultor commented 1 year ago

@rultor release, tag is 0.23.2

@yegor256 Done! FYI, the full log is here (took me 2min)

yegor256 commented 1 year ago

@php-coder I believe it's fixed. I will release 0pdd soon: https://github.com/yegor256/0pdd/issues/476

php-coder commented 1 year ago

@yegor256 It was fast! Thanks!