1 00:00:00,017 --> 00:00:04,077 Two at the same time. Yep. Yes. We're not both speaker at the same time now. 2 00:00:04,297 --> 00:00:07,917 Two first. OK dokey. Can I just control? 3 00:00:09,257 --> 00:00:14,197 OK dokey. I'm going to talk about JSON linting and JSON schema validation. 4 00:00:14,877 --> 00:00:19,437 And you all know in KDE, we love to have JSON files for package metadata, 5 00:00:19,857 --> 00:00:23,457 like included in plugins, or also for a K package. 6 00:00:24,317 --> 00:00:27,117 But in case you ever had a syntax error, like 7 00:00:27,117 --> 00:00:30,257 a missing semicolon or a missing comma in a 8 00:00:30,257 --> 00:00:33,157 JSON file the meta object compiler would just 9 00:00:33,157 --> 00:00:35,957 ignore this and print out a warning in the build and this 10 00:00:35,957 --> 00:00:40,537 is of course suboptimal if you forget to double check your build output or to 11 00:00:40,537 --> 00:00:49,717 test your changes and we also have like in kplugin metadata some logic to like 12 00:00:49,717 --> 00:00:54,617 automatically correct some data types if one expects a boolean but but a string is passed in, 13 00:00:54,697 --> 00:00:58,297 and that runtime compatibility is of course a bit ugly. 14 00:00:59,477 --> 00:01:04,117 And we have JSON or documentation for the JSON files, 15 00:01:04,797 --> 00:01:10,137 in different places, but mostly like C++ API docs, and that is sometimes a bit 16 00:01:10,137 --> 00:01:15,717 hard to discover, especially when one like combines multiple JSON schemas. 17 00:01:17,317 --> 00:01:21,057 So, and I have created schemas for the JSON files, 18 00:01:21,057 --> 00:01:24,957 and they are published on the autoconfig website of 19 00:01:24,957 --> 00:01:27,957 KDE and on CI all 20 00:01:27,957 --> 00:01:31,037 the known keys we have are validated so that 21 00:01:31,037 --> 00:01:34,137 if we expect a boolean and to be 22 00:01:34,137 --> 00:01:39,517 the type for some feature flag then it's checked that this is only a boolean 23 00:01:39,517 --> 00:01:43,357 and if it's a string which is like true then it's of course a validation error 24 00:01:43,357 --> 00:01:49,197 and you can You can also specify a more specific schema using the $schema key 25 00:01:49,197 --> 00:01:53,477 and we have various schemas available on the Autoconfig website, 26 00:01:53,777 --> 00:01:57,037 for example for applets and krunner plugins. 27 00:01:58,377 --> 00:01:59,357 And kparts. 28 00:01:59,837 --> 00:02:04,597 And you can also create your own schema utilizing some of the components, 29 00:02:04,817 --> 00:02:10,377 for example you can say you want to extend the kplugin metadata spec to have 30 00:02:10,377 --> 00:02:13,197 some additional entries for your plugin system. 31 00:02:13,197 --> 00:02:19,157 That is what KDE Connect is also doing and there I've created like a local JSON schema. 32 00:02:19,397 --> 00:02:22,397 You can see that we are using the autoconfig website 33 00:02:22,397 --> 00:02:27,437 there to pull in the schema for KPlugin metadata and also define some additional 34 00:02:27,437 --> 00:02:33,317 entries that are specific to KDE Connect and you also say that for example the 35 00:02:33,317 --> 00:02:38,757 KPlugin object and some KDE Connect specific keys are strictly required because 36 00:02:38,757 --> 00:02:40,837 because otherwise a plug-in can't properly be loaded. 37 00:02:41,197 --> 00:02:46,757 And with such a schema, you also get pretty good auto-completion from your language 38 00:02:46,757 --> 00:02:51,377 server, so that you know what you have to type in, and maybe you even get some 39 00:02:51,377 --> 00:02:54,257 suggestions, for example, with system settings categories. 40 00:02:58,977 --> 00:03:02,177 And now it's me. We're not doing JSON anymore. We're doing QML. 41 00:03:02,597 --> 00:03:06,537 So QML is amazing, but it's also runtime, which sucks. 42 00:03:06,877 --> 00:03:11,117 So I write that code, and I made a typo. 43 00:03:11,197 --> 00:03:15,597 I wrote rectangle instead of rectangle, which happens. 44 00:03:16,097 --> 00:03:21,737 I'm not a native in English. So I will go again, and then whoops, whoops, what happened? 45 00:03:25,977 --> 00:03:30,497 So I will go, and I will fix it. And I would say ID rectangle because there's a typo there. 46 00:03:30,857 --> 00:03:35,937 But then I forgot the other typo. There's inline in the penultimate line. 47 00:03:36,237 --> 00:03:40,937 I didn't fix that typo. And that will break. Your code will not run anymore. 48 00:03:41,937 --> 00:03:45,017 If you run it, you will get a runtime warning. 49 00:03:45,257 --> 00:03:49,037 But who wants a runtime warning? Runtime warnings are terrible because they 50 00:03:49,037 --> 00:03:51,617 are on runtime, and we don't test our apps. No, we do. 51 00:03:53,457 --> 00:03:58,437 But it's too late. Maybe it's in a corner case. It's in a place you seldom run, 52 00:03:58,637 --> 00:03:59,817 so you will not see the warning. 53 00:04:00,897 --> 00:04:06,157 If you run kumalint before running the app, you will get also a warning. 54 00:04:06,297 --> 00:04:11,377 It will tell you on line 9, column 24, so it's super, super specific there, 55 00:04:12,097 --> 00:04:13,517 that there is something wrong. 56 00:04:14,037 --> 00:04:17,917 I mean, the warning is not amazing, but it will point you in the right direction. 57 00:04:18,877 --> 00:04:24,717 So how do you use that? You use this new magic thing they added in Qt 6 called, 58 00:04:24,717 --> 00:04:27,877 I don't know what it's called, Qt add QML module, right? 59 00:04:28,057 --> 00:04:33,357 You add that, and then you run make all QML lint, and it will run QML lint over 60 00:04:33,357 --> 00:04:36,177 all your things, and it will give you all the warnings. 61 00:04:36,537 --> 00:04:41,917 Even better, just make your targets depend on that target, right? 62 00:04:41,977 --> 00:04:46,837 So when you run make, it will, at the end of make, or ninja if you're ninjas, 63 00:04:47,017 --> 00:04:51,177 at the end of make or ninja, will run all QML lint, and your build will fail 64 00:04:51,177 --> 00:04:52,437 if you have warnings, right? 65 00:04:52,477 --> 00:04:58,417 That's what we want. We want the CI to be read if you have QML lint warning. So do that today. 66 00:04:58,837 --> 00:05:00,657 Do that yesterday. We need that. 67 00:05:02,057 --> 00:05:06,137 And that's it. We don't have time for questions, but we are all two very pretty 68 00:05:06,137 --> 00:05:07,677 people. He a bit more prettier than me. 69 00:05:08,057 --> 00:05:11,817 So all week here, ask us questions. And yeah, right on time. 70 00:05:11,897 --> 00:05:14,317 Amazing. Thank you very much.