diff mbox series

cargo-update-recipe-crates: Use override style append so generated code passes oelint-adv.

Message ID 20240710193743.3686800-1-jeremi.graveline@gmail.com
State New
Headers show
Series cargo-update-recipe-crates: Use override style append so generated code passes oelint-adv. | expand

Commit Message

jermigra July 10, 2024, 7:37 p.m. UTC
The oelint-adv linter checks fails when linting the recipe generated when inheriting cargo-update-recipe-crates class.
It fails with the the oelint.bars.srcuriappend error. See https://github.com/priv-kweihmann/oelint-adv/blob/master/docs/wiki/oelint.vars.srcuriappend.md#oelintvarssrcuriappend
Fixed by using override style append instead of the += syntax.

Signed-off-by: jermigra <jeremi.graveline@gmail.com>
---
 meta/classes-recipe/cargo-update-recipe-crates.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexander Kanavin July 10, 2024, 8:02 p.m. UTC | #1
But does this fix any actual issue? It’s not enough to justify the change
with a ‘linter is complaining’. Reading the link, it’s about supporting a
hypothetical weak assignment to SRC_URI, which basically never happens in
real recipes.

Alex

On Wed 10. Jul 2024 at 21.47, jermigra via lists.openembedded.org
<jeremigraveline=gmail.com@lists.openembedded.org> wrote:

> The oelint-adv linter checks fails when linting the recipe generated when
> inheriting cargo-update-recipe-crates class.
> It fails with the the oelint.bars.srcuriappend error. See
> https://github.com/priv-kweihmann/oelint-adv/blob/master/docs/wiki/oelint.vars.srcuriappend.md#oelintvarssrcuriappend
> Fixed by using override style append instead of the += syntax.
>
> Signed-off-by: jermigra <jeremi.graveline@gmail.com>
> ---
>  meta/classes-recipe/cargo-update-recipe-crates.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass
> b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
> index a19ce16b46..88a5b0e4dd 100644
> --- a/meta/classes-recipe/cargo-update-recipe-crates.bbclass
> +++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
> @@ -31,7 +31,7 @@ do_update_crates() {
>  def get_crates(f):
>      import tomllib
>      c_list = '# from %s' % os.path.relpath(f, '${CARGO_LOCK_SRC_DIR}')
> -    c_list += '\nSRC_URI += " \\\'
> +    c_list += '\nSRC_URI:append = " \\\'
>      crates = tomllib.load(open(f, 'rb'))
>
>      # Build a list with crates info that have crates.io in the source
> --
> 2.25.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#201740):
> https://lists.openembedded.org/g/openembedded-core/message/201740
> Mute This Topic: https://lists.openembedded.org/mt/107149938/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
jermigra July 10, 2024, 8:29 p.m. UTC | #2
Hi,

I understand, it is true it doesn't really happen in real recipes. Is the
new version of the class bad though? I cannot find a way to suppress the
error from the recipe itself and wish not to edit the generated include
file.

Thank you !

Jérémi






On Wed, 10 Jul 2024 at 16:03, Alexander Kanavin <alex.kanavin@gmail.com>
wrote:

> But does this fix any actual issue? It’s not enough to justify the change
> with a ‘linter is complaining’. Reading the link, it’s about supporting a
> hypothetical weak assignment to SRC_URI, which basically never happens in
> real recipes.
>
> Alex
>
> On Wed 10. Jul 2024 at 21.47, jermigra via lists.openembedded.org
> <jeremigraveline=gmail.com@lists.openembedded.org> wrote:
>
>> The oelint-adv linter checks fails when linting the recipe generated when
>> inheriting cargo-update-recipe-crates class.
>> It fails with the the oelint.bars.srcuriappend error. See
>> https://github.com/priv-kweihmann/oelint-adv/blob/master/docs/wiki/oelint.vars.srcuriappend.md#oelintvarssrcuriappend
>> Fixed by using override style append instead of the += syntax.
>>
>> Signed-off-by: jermigra <jeremi.graveline@gmail.com>
>> ---
>>  meta/classes-recipe/cargo-update-recipe-crates.bbclass | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass
>> b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
>> index a19ce16b46..88a5b0e4dd 100644
>> --- a/meta/classes-recipe/cargo-update-recipe-crates.bbclass
>> +++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
>> @@ -31,7 +31,7 @@ do_update_crates() {
>>  def get_crates(f):
>>      import tomllib
>>      c_list = '# from %s' % os.path.relpath(f, '${CARGO_LOCK_SRC_DIR}')
>> -    c_list += '\nSRC_URI += " \\\'
>> +    c_list += '\nSRC_URI:append = " \\\'
>>      crates = tomllib.load(open(f, 'rb'))
>>
>>      # Build a list with crates info that have crates.io in the source
>> --
>> 2.25.1
>>
>>
>> 
>>
>>
Richard Purdie July 10, 2024, 11:16 p.m. UTC | #3
On Wed, 2024-07-10 at 16:29 -0400, jermigra via lists.openembedded.org
wrote:
> I understand, it is true it doesn't really happen in real recipes. Is
> the new version of the class bad though? I cannot find a way to
> suppress the error from the recipe itself and wish not to edit the
> generated include file. 

We're not swapping a perfectly good += for append when there isn't a
reason to. I'm on record as wanting to reduce the usage of append and
see += used more in general.

The linter needs to be fixed.

Cheers,

Richard
Alexander Kanavin July 11, 2024, 6:36 a.m. UTC | #4
On Wed, 10 Jul 2024 at 22:29, Jérémi Graveline
<jeremigraveline@gmail.com> wrote:
> I understand, it is true it doesn't really happen in real recipes. Is the new version of the class bad though? I cannot find a way to suppress the error from the recipe itself and wish not to edit the generated include file.

If I remember right, oelint's default set of checks isn't necessarily
'sensible', and it is expected that users disable the checks that
aren't helping or otherwise get in the way. You can also file a ticket
there, or send a patch.

Alex
diff mbox series

Patch

diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
index a19ce16b46..88a5b0e4dd 100644
--- a/meta/classes-recipe/cargo-update-recipe-crates.bbclass
+++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
@@ -31,7 +31,7 @@  do_update_crates() {
 def get_crates(f):
     import tomllib
     c_list = '# from %s' % os.path.relpath(f, '${CARGO_LOCK_SRC_DIR}')
-    c_list += '\nSRC_URI += " \\\'
+    c_list += '\nSRC_URI:append = " \\\'
     crates = tomllib.load(open(f, 'rb'))
 
     # Build a list with crates info that have crates.io in the source