You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "dweiss (via GitHub)" <gi...@apache.org> on 2025/06/18 19:38:19 UTC
[PR] Add support for running ast-grep rules [lucene]
dweiss opened a new pull request, #14808:
URL: https://github.com/apache/lucene/pull/14808
This is a spinoff from #14804. We should allow running ```ast-grep``` (https://ast-grep.github.io/) rules as validation checks. This is a powerful tool (and fast).
For now, running ast-grep is optional. You need to install ast-grep manually and then set this build option to the location (or name) of of the ast-grep tool:
```
lucene.tool.ast-grep=ast-grep
```
I recommend doing this in ```build-options.local.properties```. If this build option is _not set_, the entire task (ruleset) is ignored and a warning is printed.
I've set up CI jobs on github to install and run ast-grep as part of pull requests and on-commit checks for now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for running ast-grep rules [lucene]
Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on PR #14808:
URL: https://github.com/apache/lucene/pull/14808#issuecomment-2985574748
Thank you @dweiss, I was just slow, was testing it out. I set the property locally, and added rule and test:
```yaml
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/ast-grep/ast-grep/refs/heads/main/schemas/rule.json
id: java-syntax
language: java
rule:
kind: ERROR
message: Syntax Error
severity: error
```
```yaml
---
# test the parser is working
id: java-syntax
valid:
- x = 1;
```
I introduced bogus syntax to a file and the build then failed quickly on the problem (it is just an example and we probably should not do this):
```
> Task :testAstGrepRules
Running 1 tests
----------- Case Details -----------
PASS java-syntax .
test result: ok. 1 passed; 0 failed;
> Task :applyAstGrepRules
error[java-syntax]: Syntax Error
┌─ lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java:145:50
│
145 │ public List<LeafReaderContext> getLeafContexts([) {
│ ^
Error: 1 error(s) found in code.
Help: Scan succeeded and found error level diagnostics in the codebase.
> Task :applyAstGrepRules FAILED
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for running ast-grep rules [lucene]
Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss merged PR #14808:
URL: https://github.com/apache/lucene/pull/14808
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for running ast-grep rules [lucene]
Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss commented on PR #14808:
URL: https://github.com/apache/lucene/pull/14808#issuecomment-2985547456
I'll allow myself to merge this in without a review. I don't think anybody will object (but if anybody does, shout out).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for running ast-grep rules [lucene]
Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss commented on PR #14808:
URL: https://github.com/apache/lucene/pull/14808#issuecomment-2985638437
Sorry for not waiting, I wanted to proceed. Please open a new issue with those rules. This one looks very neat indeed - we can even force it to run prior to javac. It's a C based parser for java... remember jikes? :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for running ast-grep rules [lucene]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #14808:
URL: https://github.com/apache/lucene/pull/14808#issuecomment-2985485459
This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog label to it and you will stop receiving this reminder on future updates to the PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org