cli for reanalyze
for us non-vs code users, please give us a way to invoke the analyzer from a cli! :(
It's part of rescript-tools
npm install --save-dev @rescript/tools
npx rescript-tools reanalyze --help
how do i get it to actually do something? i'm running it from the same dir that rescript.json/package.json is in
❯ npx rescript-tools reanalyze -all -config -debug
Warning: can't find source dirs: lib/bs/.sourcedirs.json
Types for cross-references will not be found.
File References
Termination Analysis Stats
Files:0
Recursive Blocks:0
Functions:0
Infinite Loops:0
Hygiene Errors:0
Cache Hits:0/0
Analysis reported 0 issues
you need to build your project first in order to generate a lib/bs/.sourcedirs.json
i'm building, but it's not generated. using rescript 12 beta1
And you might need some stuff in your rescript.json? Can't remember, will take a look at my setup once back at my desk.
Forgot to add that: https://rescript-lang.org/docs/manual/v12.0.0/editor-code-analysis#configuration
❯ npx rescript-tools reanalyze -config -all -debug
Scanning lib/bs/src/Main.cmt Source:src/Main.res
after rescript legacy build the sourcedirs file was generated. but i can't get it to do more than above. i also tried putting the reanalyze section in rescript.json. no difference
is rescript v12 not supported or something? it literally doesn't do anything except output the above
right, the current published tools version is 9 months old at the very least we need to publish a new tools version first
or is anything else missing @zth ?
Rescript-tools is part of the rescript npm package since v12. If you installed it separately that will be an incompatible version.
Rescript-tools is part of the rescript npm package since v12. If you installed it separately that will be an incompatible version.
all of this is kind of confusing. how do i actually run reanalyze for rescript v12?
i actually think i got it working now by doing npx rescript legacy build and then npx rescript-tools reanalyze -all which seems to generate expected output more or less. it doesn't work without npx rescript legacy build though (because rewatch isn't generating .sourcedirs.json)
also i'm getting tons of "argument unsused" for optional arguments in functions where i actually DO use the argument, is this expected?
also this:
toMins might raise Division_by_zero (Duration.res:22:42) and is not annotated with @raises(Division_by_zero)
for:
let toMillis = (d: t): float => d
let toMins = (d: t): float => d->toMillis / 60_000.0
is there a manual on how to work with reanalyze? i'm sure it'll be helpful i just need to understand what's going on (also sorry for turning this into some general question thread)
Okay, I'm able to confirm that our new build system does not support reanalyze.
I had to use rescript legacy build to get reanalyze working. Will create an issue for that shortly.
As for config I have:
// rescript.json
"reanalyze": {
"analysis": ["dce"],
"suppress": ["src/TailwindColors.res", "src/Scenes/Design.res"]
},
And I invoke it via npx rescript-tools reanalyze -json.
Since v12, you do not need to install https://www.npmjs.com/package/@rescript/tools The binary is bundled as part of https://www.npmjs.com/package/rescript
Okay, turns out you need to pass --create-sourcedirs to your npx rescript build for rewatch to generate the lib/bs/.sourcedirs.json file in v12.
thanks, but npx rescript build --create-sourcedirs creates an empty .sourcedirs.json:
{"dirs":[],"generated":[],"pkgs":[]}
while npx rescript legacy build actually populates it
is there a way to turn off exception analysis warnings for panic calls? they don't make sense to me
also: why am i getting division_by_zero warnings for things such as x / 10? is this a bug in reanalyze?
thanks, but
npx rescript build --create-sourcedirscreates an empty .sourcedirs.json:
{"dirs":[],"generated":[],"pkgs":[]}while
npx rescript legacy buildactually populates it
Yes, I noticed that as well. We are working on a fix for that.
Thanks for your patience 🙏
thanks, but
npx rescript build --create-sourcedirscreates an empty .sourcedirs.json:{"dirs":[],"generated":[],"pkgs":[]}whilenpx rescript legacy buildactually populates itYes, I noticed that as well. We are working on a fix for that.
Thanks for your patience 🙏
no problems, appreciating your feedback. is there an appropriate place to file issues for reanalyze? i think i'm finding a few bugs
Yeah the main rescript repository would be the right place for that. Much appreciated!