wolframresearch / codeinspector Goto Github PK
View Code? Open in Web Editor NEWFind and report problems in Wolfram Language code
License: MIT License
Find and report problems in Wolfram Language code
License: MIT License
I recently noticed that codeInspector gave warnings about Quit
, Echo
and other so-called SessionSymbols here. I wonder what those warnings are about? One thing that I can think of is that these symbols are often for debugging during development, so the warning is there to remind users that there are debug symbols and should not be included in the final package?
The following reports a potential problem as expected:
CodeInspectSummarize[
"f[x_ : {}, OptionsPattern[]] := x"
]
This one should too:
CodeInspectSummarize[
"f[x_List : {}, OptionsPattern[]] := x"
]
Currently, it does not report anything.
List
is not sufficiently specific and the same issues apply as with a naked _
. OptionsPattern[]
will eat List
s.
To be clear, I am not asking for handling all cases that are not sufficiently specific. That is both unreasonable and impossible. I am asking just for _List
, which should cover a significant fraction of cases that remain after having dealt with a naked _
.
Sometimes users may define their own functions using the same name in the following list:
codeinspector/CodeInspector/Kernel/AbstractRules.wl
Lines 111 to 117 in 61b8274
I don't think it is necessary to raise them as errors. Maybe a hint?
Since there is no usage message for CodeInspectBoxSummarize is it meant to be a public symbol?
Because it is on the context path, it shows on autocompletion for CodeInspectSummarize which is what I intended to enter when I entered...
CodeInspectBoxSummarize[File["path"]]
resulting in errors:
Do::iterb: Iterator {CodeInspector`Boxes`Private`lint,CodeInspector`Boxes`Private`lints$185609} does not have appropriate bounds.
Join::heads: Heads List and CodeParser`CodeConcreteParseBox at positions 1 and 2 are expected to be the same.
ApplyTo
is new in 12.2. CodeInspect
(and co) flags it as problematic:
In[1]:= Needs["CodeInspector`"]
In[2]:= CodeInspect["f=1;f//=Sin"]
Out[2]= {
CodeInspector`InspectionObject[
"ExpectedOperand", "Expected an operand.", "Fatal",
Association[
CodeParser`Source -> {{1, 8}, {1, 8}}, ConfidenceLevel -> 1.]]}
Environment info:
In[3]:= $Version
Out[3]= "12.2.0 for Mac OS X x86 (64-bit) (December 3, 2020)"
In[4]:= PacletObject["CodeInspector"]["Version"]
Out[4]= "1.1.1"
I think the line PacletInstall["CodeFormatter"]
should be added to the installation instructions for versions below 12.2 (I have 12.1 myself), where it says to install with PacletInstall["CodeParser"] PacletInstall["CodeInspector"]
. Otherwise I get the error Error Get::noopen: Cannot open CodeFormatter
.`
The code error Which[a, b, a, c]
gets picked up by the plugin, but a related one like Which[a, b, c]
does not. Presumably this is because CodeInspect assigns a relatively low confidence (0.55) to this case?
CodeInspect["Which[a, b, a, c]"]
CodeInspect["Which[a, b, c]"]
This is rather unfortunate, since this is a pretty important and common error to catch. I don't know what the proper solution is, but I feel like this is worth addressing.
Hi, I wonder if there's a valid range for unicode characters that can appear in identifiers? Currently, Cyrillic letters, CJK characters, and other letterlike characters (like emoji ๐) will generate the [UnexpectedLetterlikeCharacter] Unexpected letterlike character: \:xxxx
warning., e.g.
In[] := CodeInspect["\\:0438=1"]
Out[] := {
CodeInspector`InspectionObject[
"UnexpectedLetterlikeCharacter",
"Unexpected letterlike character: ``\\:0438``.", "Warning",
Association[
CodeParser`Source -> {{1, 1}, {1, 7}}, ConfidenceLevel -> 0.8]]}
The current version (1.2) seems only available on MMA 12.3. Do we have the plan to upload it to the official paclet server for earlier versions?
The following MWE shows that CodeInspector
does not recognize the language tag in message names.
In[1]:= Needs["CodeParser`"]
In[2]:= Needs["CodeInspector`"]
In[3]:= CodeInspect["symbol::usage=\"symbol usage message.\""]
Out[3]= {}
In[4]:= CodeInspect["symbol::usage::English=\"symbol usage message in English.\""]
Out[4]= {MessageName Error Unexpected argument to MessageName.}
In[5]:= CodeInspect["symbol::usage::French=\"message d'utilisation du symbole en francais.\""]
Out[5]= {MessageName Error Unexpected argument to MessageName.}
I'm writing WL in Vim and using wolframscript
and would love to be able to have my files checked on save (or even integrate it with tools like ALE). Would it be possible to get the summary of issues in some human readable form?
I tried Print[CodeInspectSummarize[File["match_distribution.wl"]]]
and now have permanent eye damage ;) :D
But seriously, this is a very cool tool! Keep up the good work!
Hi! The following code snippet
CodeInspectSummarize[
"{foo[a_,b_]:>bar1[a,b]/;a=!=b, foo[a_,b_]:>bar2[a,b]/;a===b}"]
triggers a warning, yet the code works as expected.
Of course one could debate whether the conditionals should be always put before :>
or not, but I'm curious if the given example really should be considered problematic
from the technical point of view.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.