Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/WolframResearch/codeinspector
Find and report problems in Wolfram Language code
https://github.com/WolframResearch/codeinspector
codeinspector codetools lint linter linting mathematica static-analysis wolfram-language wolfram-mathematica
Last synced: 2 months ago
JSON representation
Find and report problems in Wolfram Language code
- Host: GitHub
- URL: https://github.com/WolframResearch/codeinspector
- Owner: WolframResearch
- License: mit
- Created: 2020-04-08T18:42:03.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-19T12:12:30.000Z (about 2 years ago)
- Last Synced: 2024-08-05T09:11:40.725Z (6 months ago)
- Topics: codeinspector, codetools, lint, linter, linting, mathematica, static-analysis, wolfram-language, wolfram-mathematica
- Language: Mathematica
- Homepage:
- Size: 3.94 MB
- Stars: 64
- Watchers: 21
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-wolfram-language - codeinspector
README
# CodeInspector
CodeInspector is a package for finding and reporting problems in Wolfram Language code.
CodeInspector has a large collection of rules that can be used to inspect Wolfram Language source code files and can be customized to your preferences.In a stand-alone kernel:
```
Needs["CodeInspector`"]CodeInspectSummarize["If[a,b,b]"]
```
```
Out[2]= If[a,b,b]line 1: If[a,b,b]
^ ^
DuplicateClauses Error Both branches are the same.
```In a front end:\
![CodeInspectSummarize](docs/summarize.png)[Static Analysis Tools in the Wolfram Language](https://blog.wolfram.com/2021/04/06/static-analysis-tools-in-the-wolfram-language/)
["CodeParser and CodeInspector" on community.wolfram.com](https://community.wolfram.com/groups/-/m/t/1931315)
[Finding Bugs in the Wolfram Language from WTC 2019: Watch Video (youtube)](https://www.youtube.com/watch?v=jMUVwLglt-c)
[Finding Bugs in the Wolfram Language from WTC 2019: Watch Video (wolfram.com)](https://www.wolfram.com/broadcast/video.php?v=2911)
[Finding Bugs in the Wolfram Language from WTC 2019: Download Presentation](https://files.wolframcdn.com/pub/www.wolfram.com/technology-conference/2019/Thursday/2019BrentonBostickFindingBugsInTheWL.nb)
## Setup
CodeInspector depends on [CodeParser paclet](https://github.com/WolframResearch/codeparser) and [CodeFormatter paclet](https://github.com/WolframResearch/codeformatter).
CodeInspector and its dependencies are included in Mathematica 12.2 and above.
For older versions, install CodeInspector paclet and dependencies from the public paclet server:
```
PacletInstall["CodeParser"]
PacletInstall["CodeFormatter"]
PacletInstall["CodeInspector"]
```[Build and install the CodeInspector paclet locally](HowToBuild.md)
## Using CodeInspector
After CodeParser and CodeInspector are installed, CodeInspector can be used.
Return the list of all problems found in a string of code:
```
Needs["CodeInspector`"]CodeInspect["If[a,b,b]"]
```
```
Out[2]= {DuplicateClauses Error Both branches are the same.}
```Summarize the problems found in a source code file:
![Collatz](docs/collatz.png)
The input to `CodeInspect` and `CodeInspectSummarize` may be a string, a `File`, or a list of bytes.
See this tutorial in the Wolfram System help browser:
* CodeInspector/tutorial/CodeInspectorTutorial
## Troubleshooting
Make sure that the paclets can be found on your system:
```
Needs["CodeInspector`"]
```and try a basic example:
```
CodeInspect["If[a, b, b]"]
```