-
Notifications
You must be signed in to change notification settings - Fork 175
Remove id
from paths to instances in style warnings
#306
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
base: master
Are you sure you want to change the base?
Conversation
It is. I recently extended the 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 |
533c134
to
4ed5981
Compare
@generalmimon, could you look again? This PR fixes 13 errors |
d2a946b
to
af582ae
Compare
@GreyCat, @generalmimon , this PR reduces error count from currently 54 to 42. It is small win, do you mind to merge it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, looks good to me and relatively straightforward fix! Thanks @Mingun!
@generalmimon, do you have any concerns or shall we merge this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine too, it indeed fixes some of the test failures.
You know I'm not a big fan of adding comments unless it's absolutely necessary, but if you do, I'd prefer them to make sense...
shared/src/main/scala/io/kaitai/struct/precompile/StyleCheckIds.scala
Outdated
Show resolved
Hide resolved
shared/src/main/scala/io/kaitai/struct/precompile/StyleCheckIds.scala
Outdated
Show resolved
Hide resolved
shared/src/main/scala/io/kaitai/struct/precompile/StyleCheckIds.scala
Outdated
Show resolved
Hide resolved
shared/src/main/scala/io/kaitai/struct/precompile/ResolveTypes.scala
Outdated
Show resolved
Hide resolved
shared/src/main/scala/io/kaitai/struct/precompile/ResolveTypes.scala
Outdated
Show resolved
Hide resolved
shared/src/main/scala/io/kaitai/struct/precompile/ResolveTypes.scala
Outdated
Show resolved
Hide resolved
|
||
def resolveUserType(curClass: ClassSpec, dataType: DataType, path: List[String]): Iterable[CompilationProblem] = { | ||
/** | ||
* Resolves the type of the `dataType` of an attribute defined in `curClass`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what "the type of the dataType
" means, maybe just
* Resolves the type of the `dataType` of an attribute defined in `curClass`. | |
* Resolves the `dataType` of an attribute defined in `curClass`. |
...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is reference to user-defined class (and maybe to built-in type? Don't remember. Affected by the lack of documentation, so I cannot agree with your statement that something is obvious here...). By the way, the whole procedure looks complicated and buggy, but it is fixed in #309
Fixes kaitai-io/kaitai_struct#920 Error count: 54 -> 50 (-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: 50 -> 43 (-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)
Error count: 43 -> 42 (-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)
af582ae
to
b868509
Compare
@generalmimon, your suggestion applied |
It seems relatively new error, but the code was not changed since 2021...
Fixes errors like:
/instances/size_of_foo/id
is not-existing path. Instances does not haveid
, the name of instance is itsid
.Fixes kaitai-io/kaitai_struct#920.
Also fixes a couple of other errors