Skip to content
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

Problem when multiple lines #193

Open
bastien70 opened this issue Dec 27, 2021 · 7 comments
Open

Problem when multiple lines #193

bastien70 opened this issue Dec 27, 2021 · 7 comments
Labels
ruleset customization When an issue should be solved with a custom ruleset

Comments

@bastien70
Copy link

bastien70 commented Dec 27, 2021

Hello, I've the following code :

{% set head_of_service_and_can_credit = is_granted(constant('App\\Application\\Entity\\User::ROLE_CHEF_SERVICE'))
        and not is_granted(constant('App\\Application\\Entity\\User::ROLE_RH'))
        and headOfServiceTypesAuthorizationCount > 0
        and user.service.headOfService.validator.id == app.user.id
    %}

And the following errors :

l.11 c.117 : ERROR There should be 1 space between the "and" operator and its left operand.
l.12 c.79 : ERROR There should be 1 space between the "and" operator and its left operand.
l.13 c.52 : ERROR There should be 1 space between the "and" operator and its left operand.

These errors will only be resolved if I put everything on one line but I don't want it because the line will be too long. How can I fix this kind of problem?

Same here :

{% extends is_granted(constant('App\\Application\\Entity\\User::ROLE_SUPER_ADMIN'))
    ? "admin/base.html.twig"
    : "base.html.twig"
%}
l.1 c.83 : ERROR There should be 1 space before the "?".
l.2 c.29 : ERROR There should be 1 space before the ":".

Same, if I put it on one line it will work, but afterwards the line becomes too long

@ghost
Copy link

ghost commented Jan 14, 2022

Hi, I think I have the same problem.

Is there a way to tell twigcs to ignore this line?

{% if
    globalAuth.care_user_log_truncate == 1 or globalAuth.care_comment_truncate == 1 or
    globalAuth.care_content_truncate == 1 or globalAuth.care_all_images_truncate == 1 or
    globalAuth.care_session_truncate == 1 or globalAuth.care_content_keyword == 1 or
    globalAuth.care_passive_users_truncate == 1
%}

sc

@MichaelAllenWarner
Copy link

@bastien70 @libreajans

Try replacing enforceSize(...) with enforceSpaceOrLineBreak(...) where appropriate in RulesetBuilder.php. For the ternaries, that would be lines 225 and 227.

@OwlyCode
Copy link
Collaborator

I'm sorry I didn't answer sooner to this issue. Are you still facing the problem or did you manage to configure your own ruleset?

@OwlyCode OwlyCode added the ruleset customization When an issue should be solved with a custom ruleset label Apr 28, 2022
@gnutix
Copy link

gnutix commented May 29, 2022

I too encountered this issue. Ended up creating variables just to make the code readable...

@RSickenberg
Copy link

RSickenberg commented Aug 2, 2022

Same issue, but I duplicated it with more context, sorry. (Ref: #254)

@danog
Copy link

danog commented Nov 15, 2022

Still encountering this issue on v6 :(

@bastien70
Copy link
Author

Yeah still encountering the issue too :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ruleset customization When an issue should be solved with a custom ruleset
Projects
None yet
Development

No branches or pull requests

6 participants