twigcs
twigcs copied to clipboard
Problem when multiple lines
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
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
%}
@bastien70 @libreajans
Try replacing enforceSize(...)
with enforceSpaceOrLineBreak(...)
where appropriate in RulesetBuilder.php
. For the ternaries, that would be lines 225 and 227.
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?
I too encountered this issue. Ended up creating variables just to make the code readable...
Same issue, but I duplicated it with more context, sorry. (Ref: https://github.com/friendsoftwig/twigcs/issues/254)
Still encountering this issue on v6 :(
Yeah still encountering the issue too :(