dialyzer.asciidoc 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. [[dialyzer]]
  2. == Dialyzer
  3. Dialyzer is a tool that will detect discrepancies in your
  4. program. It does so using a technique known as success
  5. typing analysis which has the advantage of providing no
  6. false positives. Dialyzer is able to detect type errors,
  7. dead code and more.
  8. Erlang.mk provides a wrapper around Dialyzer.
  9. === How it works
  10. Dialyzer requires a PLT file to work. The PLT file contains
  11. the analysis information from all applications which are not
  12. expected to change, or rarely do. These would be all the
  13. dependencies of the application or applications you are
  14. currently working on, including standard applications in
  15. Erlang/OTP itself.
  16. Dialyzer can generate this PLT file. Erlang.mk includes rules
  17. to automatically generate the PLT file when it is missing.
  18. Once the PLT file is generated, Dialyzer can perform the
  19. analysis in record time.
  20. === Configuration
  21. In a typical usage scenario, no variable needs to be set.
  22. The defaults should be enough. Do note however that the
  23. dependencies need to be set properly using the `DEPS` and
  24. `LOCAL_DEPS` variables.
  25. The `DIALYZER_PLT` file indicates where the PLT file will
  26. be written to (and read from). By default this is
  27. '$(PROJECT).plt' in the project's directory. Note that
  28. the `DIALYZER_PLT` variable is exported and is understood
  29. by Dialyzer directly.
  30. The `PLT_APPS` variable can be used to add additional
  31. applications to the PLT. You can either list application
  32. names or paths to these applications.
  33. Erlang.mk defines two variables for specifying options
  34. for the analysis: `DIALYZER_DIRS` and `DIALYZER_OPTS`.
  35. The former one defines which directories should be part
  36. of the analysis. The latter defines what extra warnings
  37. Dialyzer should report.
  38. Note that Erlang.mk enables the race condition warnings
  39. by default. As it can take considerably large resources
  40. to run, you may want to disable it on larger projects.
  41. === Usage
  42. To perform an analysis, run the following command:
  43. [source,bash]
  44. $ make dialyze
  45. This will create the PLT file if it doesn't exist.
  46. The analysis will also be performed when you run the
  47. following command, alongside tests:
  48. [source,bash]
  49. $ make check
  50. You can use the `plt` target to create the PLT file if
  51. it doesn't exist. This is normally not necessary as
  52. Dialyzer creates it automatically.
  53. The PLT file will be removed when you run `make distclean`.