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

Remove id from paths to instances in style warnings #306

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Mingun
Copy link
Contributor

@Mingun Mingun commented Sep 8, 2024

It seems relatively new error, but the code was not changed since 2021...

Fixes errors like:

[info] - style_bad_num_inst_value *** FAILED ***
[info]   [style_bad_num_inst_value.ksy: /instances/size_of_foo/id:
[info]   	warning: use `num_foos` instead of `size_of_foo`, given that it's only used as repeat count of `foos` (see https://doc.kaitai.io/ksy_style_guide.html#attr-id)
[info]   ]
[info]     did not equal
[info]   [style_bad_num_inst_value.ksy: /instances/size_of_foo:
[info]   	warning: use `num_foos` instead of `size_of_foo`, given that it's only used as repeat count of `foos` (see https://doc.kaitai.io/ksy_style_guide.html#attr-id)
[info]   ] (SimpleMatchers.scala:34)

/instances/size_of_foo/id is not-existing path. Instances does not have id, the name of instance is its id.

Fixes kaitai-io/kaitai_struct#920.

Also fixes a couple of other errors

@generalmimon
Copy link
Member

generalmimon commented Sep 8, 2024

@Mingun:

It seems relatively new error

It is. I recently extended the formats_err test suite: kaitai-io/kaitai_struct_tests@c5f366f...0427d48

The tests you're fixing here were added in kaitai-io/kaitai_struct_tests@c911e0a to demonstrate kaitai-io/kaitai_struct#920. So ideally you should add Fixes https://github.com/kaitai-io/kaitai_struct/issues/920 to the PR description and commit message.

@Mingun Mingun marked this pull request as draft September 8, 2024 11:11
Fixes kaitai-io/kaitai_struct#920

Error count: 62 -> 58 (-4). Fixed:

[info] - style_bad_len_inst_pos *** FAILED ***
[info]   [style_bad_len_inst_pos.ksy: /instances/size_of_foo/id:
[info]          warning: use `len_foo` instead of `size_of_foo`, given that it's only used as a byte size of `foo` (see https://doc.kaitai.io/ksy_style_guide.html#attr-id)
[info]   ]
[info]     did not equal
[info]   [style_bad_len_inst_pos.ksy: /instances/size_of_foo:
[info]          warning: use `len_foo` instead of `size_of_foo`, given that it's only used as a byte size of `foo` (see https://doc.kaitai.io/ksy_style_guide.html#attr-id)
[info]   ] (SimpleMatchers.scala:34)
[info] - style_bad_len_inst_value *** FAILED ***
[info]   [style_bad_len_inst_value.ksy: /instances/size_of_foo/id:
[info]          warning: use `len_foo` instead of `size_of_foo`, given that it's only used as a byte size of `foo` (see https://doc.kaitai.io/ksy_style_guide.html#attr-id)
[info]   ]
[info]     did not equal
[info]   [style_bad_len_inst_value.ksy: /instances/size_of_foo:
[info]          warning: use `len_foo` instead of `size_of_foo`, given that it's only used as a byte size of `foo` (see https://doc.kaitai.io/ksy_style_guide.html#attr-id)
[info]   ] (SimpleMatchers.scala:34)
[info] - style_bad_num_inst_pos *** FAILED ***
[info]   [style_bad_num_inst_pos.ksy: /instances/size_of_foo/id:
[info]          warning: use `num_foos` instead of `size_of_foo`, given that it's only used as repeat count of `foos` (see https://doc.kaitai.io/ksy_style_guide.html#attr-id)
[info]   ]
[info]     did not equal
[info]   [style_bad_num_inst_pos.ksy: /instances/size_of_foo:
[info]          warning: use `num_foos` instead of `size_of_foo`, given that it's only used as repeat count of `foos` (see https://doc.kaitai.io/ksy_style_guide.html#attr-id)
[info]   ] (SimpleMatchers.scala:34)
[info] - style_bad_num_inst_value *** FAILED ***
[info]   [style_bad_num_inst_value.ksy: /instances/size_of_foo/id:
[info]          warning: use `num_foos` instead of `size_of_foo`, given that it's only used as repeat count of `foos` (see https://doc.kaitai.io/ksy_style_guide.html#attr-id)
[info]   ]
[info]     did not equal
[info]   [style_bad_num_inst_value.ksy: /instances/size_of_foo:
[info]          warning: use `num_foos` instead of `size_of_foo`, given that it's only used as repeat count of `foos` (see https://doc.kaitai.io/ksy_style_guide.html#attr-id)
[info]   ] (SimpleMatchers.scala:34)
…TH" errors

Error count: 58 -> 51 (-7). Fixed:

[info] - id_clash_params_vs_inst_pos *** FAILED ***
[info]   [id_clash_params_vs_inst_pos.ksy: /instances/foo:
[info]          error: duplicate attribute ID 'foo', previously defined at /params/0
[info]   ]
[info]     did not equal
[info]   [id_clash_params_vs_inst_pos.ksy: /instances/foo:
[info]          error: duplicate attribute ID 'foo', previously defined at /params/0/id
[info]   ] (SimpleMatchers.scala:34)
[info] - id_clash_params_vs_inst_value *** FAILED ***
[info]   [id_clash_params_vs_inst_value.ksy: /instances/bar:
[info]          error: duplicate attribute ID 'bar', previously defined at /params/1
[info]   ]
[info]     did not equal
[info]   [id_clash_params_vs_inst_value.ksy: /instances/bar:
[info]          error: duplicate attribute ID 'bar', previously defined at /params/1/id
[info]   ] (SimpleMatchers.scala:34)
[info] - id_clash_params_vs_seq *** FAILED ***
[info]   [id_clash_params_vs_seq.ksy: /seq/0:
[info]          error: duplicate attribute ID 'foo', previously defined at /params/1
[info]   ]
[info]     did not equal
[info]   [id_clash_params_vs_seq.ksy: /seq/0/id:
[info]          error: duplicate attribute ID 'foo', previously defined at /params/1/id
[info]   ] (SimpleMatchers.scala:34)
[info] - id_clash_seq_vs_inst_pos *** FAILED ***
[info]   [id_clash_seq_vs_inst_pos.ksy: /instances/foo:
[info]          error: duplicate attribute ID 'foo', previously defined at /seq/0
[info]   ]
[info]     did not equal
[info]   [id_clash_seq_vs_inst_pos.ksy: /instances/foo:
[info]          error: duplicate attribute ID 'foo', previously defined at /seq/0/id
[info]   ] (SimpleMatchers.scala:34)
[info] - id_clash_seq_vs_inst_value *** FAILED ***
[info]   [id_clash_seq_vs_inst_value.ksy: /instances/bar:
[info]          error: duplicate attribute ID 'bar', previously defined at /seq/1
[info]   ]
[info]     did not equal
[info]   [id_clash_seq_vs_inst_value.ksy: /instances/bar:
[info]          error: duplicate attribute ID 'bar', previously defined at /seq/1/id
[info]   ] (SimpleMatchers.scala:34)
[info] - id_dup_params *** FAILED ***
[info]   [id_dup_params.ksy: /params/2:
[info]          error: duplicate attribute ID 'foo', previously defined at /params/0
[info]   ]
[info]     did not equal
[info]   [id_dup_params.ksy: /params/2/id:
[info]          error: duplicate attribute ID 'foo', previously defined at /params/0/id
[info]   ] (SimpleMatchers.scala:34)
[info] - id_dup_seq *** FAILED ***
[info]   [id_dup_seq.ksy: /seq/2:
[info]          error: duplicate attribute ID 'foo', previously defined at /seq/0
[info]   ]
[info]     did not equal
[info]   [id_dup_seq.ksy: /seq/2/id:
[info]          error: duplicate attribute ID 'foo', previously defined at /seq/0/id
[info]   ] (SimpleMatchers.scala:34)
…t you have $KS_VERSION" error

Errors count: 51 -> 50 (-1). Fixed:

[info] - meta_high_version *** FAILED ***
[info]   [meta_high_version.ksy: /meta:
[info]          error: this ksy requires compiler version at least 99.99.99, but you have $KS_VERSION
[info]   ]
[info]     did not equal
[info]   [meta_high_version.ksy: /meta/ks-version:
[info]          error: this ksy requires compiler version at least 99.99.99, but you have $KS_VERSION
[info]   ] (SimpleMatchers.scala:34)
@Mingun Mingun force-pushed the fix-excess-id-in-path branch from 533c134 to 4ed5981 Compare September 8, 2024 11:53
@Mingun Mingun marked this pull request as ready for review September 8, 2024 11:54
Error count: 50 -> 49 (-1). Fixed:

[info] - type_unknown_switch *** FAILED ***
[info]   [type_unknown_switch.ksy: /seq/0/type/cases/IntNum(42)/type:
[info]          error: unable to find type 'some_unknown_name', searching from type_unknown_switch
[info]   ]
[info]     did not equal
[info]   [type_unknown_switch.ksy: /seq/0/type/cases/IntNum(42):
[info]          error: unable to find type 'some_unknown_name', searching from type_unknown_switch
[info]   ] (SimpleMatchers.scala:34)
@Mingun
Copy link
Contributor Author

Mingun commented Sep 10, 2024

@generalmimon, could you look again? This PR fixes 13 errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Path in warnings related to ids of instances is wrong
2 participants