-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Textrule header_copyright only checks the first file passed #257
Comments
Note that my example assumes that a |
That's a bit of an oversight from me, sorry! Option1: Change the API only for Option2: Change the API for both Option3: Change Can you think of some more options? Personally, I'm leaning towards Option3. |
- I've called this Option3 in the comments of dalance#257. - Clone of `config` might be avoided, but this is the lowest-effort change.
Option4 could be to give the name of the file being parsed to the linter. Maybe Option2 could be implemented by passing an I do have an issue with Option 3 because I wrote a (syntax) rule that relies on the fact that it is not reset between file. I would also point that the filename, line number, and EOF "signal" are not exclusive features - even if reducing how much we break backwards compatibility is important. While the same result can be achieved from simply passing the filename and letting each rule deduce the EOF or the line number, those seem like they could become common among future rules. Giving all those informations would prevent every rule to reimplement the line number tracking and such. Lastly, for Option1, I would pass a structure (maybe named I prefer Option1, especially if we pass a structure instead. |
- I've called this Option3 in the comments of dalance#257. - Clone of `config` might be avoided, but this is the lowest-effort change.
Interesting :) An alternative could be to only look for option.re_forbidden_class_extends = ".*"
option.re_forbidden_class_extends_match ="^uvm_"
syntaxrules.re_forbidden_class_extends = true Pehaps I misunderstand the need for building the tree... |
I have assumed that plugins should be compatible with svls, where you can only see one file at a time. One problem I see with Option 1/2/4 is that commands like Keeping state between files means that each rule is effectively a little independent compiler (like your class tree builder)! That is cool but I'm not sure if this is the right place. I think we need @dalance to give an opinion here.
|
Well if it was just what I'd call "1st order inheritance", there would be no issue. I do that to detect "nth order inheritance". As an example: class X extends uvm; 2nd order would be class Y extends uvm;
...
class X extends Y; In both cases, I would want my rule to do something based on the knowledge that X extends uvm
If plugin rules can't be used with svls there is no reason for them to be compatible. That being said, I would be happy to use my plugins with svls =).
I do agree that simply the path would not work in that case, but I don't see how the line number and the EOF signal would fail ?
I'm rooting for you =) |
Cool. That makes sense.
Good point! I've just modified a PR for that along with the new API dalance/svls#216. |
- Called Option1 in dalance#257.
I'm thinking of other rules with similar logic to your UVM class one like Only one top module allowed or Duplicate (package|module|class|program) name detected. The path is already passed to syntaxrules in the `ifdef MODULE_NOT_PACKAGE
module mod_foo;
`else
package pkg_foo;
`endif
localparam HELLO = 123;
// ... lots more localparams
`ifdef MODULE_NOT_PACKAGE
endmodule
`else
endpackage
`endif ... and maybe processed twice with |
I think we're converging on a choice between two solutions.
...Now I'm starting to prefer Option1 too. |
I hadn't ever realised that!
I won't be able to look into that before next week.
I notice that in the implementation of |
No rush man!
I went for a SOF signal instead of an EOF because I think it's a bit easier to think about writing rules. Using an EOF signal would mean we need to think about both the initialisation and the EOF, but using an SOF signal we only need to think about the initialisation. How I wish more people would think about POSIX lines haha! However, to avoid issues of different behaviour between Windows and everything else, I purposefully stripped the |
Oh, right, I was confused! When there is a newline at the end of a file, text editors effectively show another line, so I was expecting to see an empty string before EOF. Indeed, besides that I don't see a particular need for reporting errors on SOF/EOF.
It's at least not true of VSCode! I configured mine to remove trailing whitespaces and add a newline at the end of the file whenever I save the file. Although it should probaly be enabled by default... I think you could go ahead with you PR. =) |
I caught up on the discussion. I agree the Option1 is better. |
- Same issue as <dalance/svlint#257> - Matches <dalance/svlint#261>.
That sounds less confusing :) I'll make the changes now. |
- More descriptive than `Option<&str>`. - Same issue as <dalance/svlint#257> - Matches <dalance/svlint#261>.
I tried that out on VSCode on windows and I have a couple issues:
I'll try to go deeper tomorrow! |
That is strange. I've been testing with svlint-plugin-sample and see all the expected messages about |
Interesting edge case. If it's failing to parse As long as using |
Ok so I restarted from scratch, and it seems I had broken something while dealing with the windows path issue. It seems to work out of the box.
I tested using single quotes and doubling all the
What happened was that my textrules worked fine, but a parsing error occurred before the syntaxrules could run. It would be useful if svls gave an error message in those cases. Arguably, svlint already knows what/where the error is so that could be shown in the editor as any other error ? (for reference the error was an undefined macro) Finally, it seems everytime svls reruns the linter on the file (upon modification), errors originating from plugins seem to accumulate. |
Phew! :) Good to hear.
Again, phew! Just a TOML thing (not a bug). I have seen similar types of strange behaviour. When I open Vim+vim-lsp with (1 file, 1 buffer, 1 tab) everything works as expected, but when I open different numbers of files, buffers, and tabs then I sometimes get repeated messages. I haven't done a full range of experiments yet, but it looks quite dependent on editor setup. |
svlint does seem to work fine! I'm not sure opening an issue on svls is the right thing to do since the issue seems related to plugins which are added by dalance/svls#216 which isn't merged yet. Shouldn't I just reference this issue in the pull request ? Again, I'm not particularly used to how thing go on github... ^^' |
Good point, let's wait to see what @dalance thinks and if the PRs get merged. |
@skjdbg With v0.9.0 released, I think this can be closed? |
Sorry, I missed it ! |
When passing multiple files at once to svlint, header_copyright ignores all files after the first.
For instance with:
file1.sv
and file2.sv
Calling
svlint -v path/to/file1.sv path/to/file2.sv
returns:I would expect both files to fail instead.
Looking at the implementation of header_copyright, I see that
linenum
is never reset to 1. which seems to be the cause of the bug.This brings me to the next issue: There seems to be no way for a
TextRule
(or aSyntaxRule
for all that matters) to detect the end of a file, which could be used to trigger the reset oflinenum
.The text was updated successfully, but these errors were encountered: