Comments (10)
While this is not yet solved, you can still use the comment introduced in https://github.com/allocine/twigcs/pull/44 to ignore those cases :
{% block repeated_content_block %} {% include my_module with { some_params, my_var } %} {% endblock %}
{% for item in something %}
{% set my_var = loop.index %}
{# twigcs use-var my_var #}
{{ block("repeated_content_block") }}
{% endfor %}
from twigcs.
At last, the original bug of this issue has been fixed! Any other encountered bug should be reported in a separate issue so I can track it and work on it.
from twigcs.
As far as I know, it looks at the rules per-file.
It makes sense to add some kind of "ignore" mode for cases like this.
from twigcs.
Having the same "false positive" issue with inheritance, isn't there any way to disable linter on a specific line or block yet ?
from twigcs.
We are also working on a fix
from twigcs.
Hi,
I have similar issue with embed :
{% set nav = { 'foo': 'foo' %}
{% embed 'template.html.twig' with nav only %}
...
and receive :
l.36 c.31 : WARNING Unused variable "nav".
1 violation(s) found
Edit : solved and nothing commun with initial subject.
from twigcs.
As far as I know, it looks at the rules per-file.
It makes sense to add some kind of "ignore" mode for cases like this.
It's not only the bridge between the file that includes and the include file itself, it's also within the file that includes itself; even when using a with
, followed by a variable declared in the same file, the variables use count isn't affected by it. Which obviously should set the variable to used.
Apart from already mentioned issues above, the same issue (variable not used) is even there when using a variable inside the switch statement ({% switch variable %}
) on a variable declared in the same file. That's a pretty basic structure.
To my surprise these 'not used' issues seem to be a long standing issue, being open for two years now (!). That's a long time for something happening in most basic Twig files. All above situations aren't particularly rare cases, but indeed very standard. Sorry to say, love to have a checker for Twig and thanks a lot for building this, but on the other hand, a checker throwing these kind of warnings isn't very much of use unfortunately.
Any chance this could get some love and be fixed in the near future?
from twigcs.
Hello @Friksel and thank you for this reality check. I'm aware this is a long standing issue but please keep in mind that this is an open source project, which means it is mostly maintained on everybody's free time.
I don't know if I'll work on this anytime soon because I already struggle to get time for other important topics of that project. I know @Ciloe made some research on the topic but this was far from ready to get merged (and turned out to be a huge workload).
If you do really want to see this in the near future, the best way is to come help us with some research or PRs :)
from twigcs.
Hi @OwlyCode no worries. I perfectly understand. We are all busy. Just think you guys should know as I was using this checker via an extension in VS Code, but had to de-install it this week, as it was throwing false check-messages that just aren't true and that just is counter productive. To be blunt: what's the use of having a checker if it's throwing all kinds of false warnings? That's pretty unreliable and than I'd rather have no checker at all.
If you like to fix these things that would be awesome. If you don't that's fine with me too and totally understandable and fully up to you ofcourse. I just think it's fair that I, as a user, communicate to you guys the issues I am facing first, before leaving. So that you are aware and can do something about it if you care, it has your priority and you have the time. As I am not the only one having these issues and probably others just left without even telling why. I would rather hear from users if they are facing issues before they leave.
That said, nothing personal ofcourse and I know where you're coming from. Just communicate. Keep up the great work. It's nice to have a checker for Twig. If these issues are fixed I'll re-install it.
from twigcs.
@OwlyCode That's great news! Thanks! Looking forward to the new version!
from twigcs.
Related Issues (20)
- Ability to exclude files (not only dirs) and/or limit sniffing to git diff HOT 1
- Please publish the new release (for symfony 6 use) HOT 2
- Problem when multiple lines HOT 7
- Invalid version value HOT 1
- Support request: How to disable verification of a code fragment? HOT 2
- Support config files with `.php` extension HOT 1
- Spacing of default values in macros HOT 2
- SEVERITY_IGNORE not working
- RegEngine is not happy with breaklines
- Unused variable should not be trigger if the child mutate a parent's variable. HOT 1
- Support for ??? "Empty Coalesce" operator HOT 1
- Variables set and used in loop should not be marked as unused HOT 2
- PHP 8.2 deprecations
- Supporting `createTemplate()`
- Configure cache file location HOT 2
- Avoid useless whitespace control
- Detect Twig depreciations
- PHP 8.3 support HOT 3
- [IMPORTANT] Future of the library HOT 3
- Release for the PHP 8.3 support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twigcs.