Code Monkey home page Code Monkey logo

Comments (10)

OwlyCode avatar OwlyCode commented on June 16, 2024 5

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.

OwlyCode avatar OwlyCode commented on June 16, 2024 2

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.

frvge avatar frvge commented on June 16, 2024 1

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.

AlexiZ avatar AlexiZ commented on June 16, 2024

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.

Ciloe avatar Ciloe commented on June 16, 2024

We are also working on a fix

from twigcs.

mazarini avatar mazarini commented on June 16, 2024

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.

Friksel avatar Friksel commented on June 16, 2024

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.

OwlyCode avatar OwlyCode commented on June 16, 2024

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.

Friksel avatar Friksel commented on June 16, 2024

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.

Friksel avatar Friksel commented on June 16, 2024

@OwlyCode That's great news! Thanks! Looking forward to the new version!

from twigcs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.