-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
Improve "Pub Points" on pub.dev #90
Comments
That's a great idea. |
Currently working on the "Pass static analysis" score (for |
Thanks @monsieurtanuki |
Hi @PrimaelQuemerais! factory SearchResult.fromJson(Map<String, dynamic> json) =>
_$SearchResultFromJson(json); But you changed it months ago, and now |
Hi @Grumpf! http.Response response = await http.get(entry.value);
List<int> fileBytes = response?.bodyBytes; Could you please have a look at it? If you do that I'll give you 10 points, fair is fair :) |
Well, not everything is clear in my mind now, but we're getting closer to 110 points. We lose 10 points because of this: "At least 20% of the public API members contain API documentation." And there's something I don't get about For the record: |
Hi @monsieurtanuki, |
Thank you @PrimaelQuemerais for your answer. I think the correct way out of this would be
|
fix/#90 - matching the coding rules in order to get a better pub.dev score
The right thing to do would be to get rid of static Future<SearchResult> queryPnnsGroup(
User user, PnnsGroupQueryConfiguration configuration,
{QueryType queryType = QueryType.PROD}) async {
const outputFormat = OutputFormat(format: Format.JSON);
var queryParameters = configuration.getParametersMap();
queryParameters[outputFormat.getName()] = outputFormat.getValue();
var searchUri = Uri(
scheme: URI_SCHEME,
host: queryType == QueryType.PROD ? URI_PROD_HOST : URI_TEST_HOST,
path: '/pnns-group-2/${configuration.group.id}/${configuration.page}',
queryParameters: queryParameters);
Response response = await HttpHelper()
.doGetRequest(searchUri, user: user, queryType: queryType);
var result = SearchResult.fromJson(json.decode(response.body));
if (configuration.fields
.contains(ProductField.CATEGORIES_TAGS_TRANSLATED) ||
configuration.fields.contains(ProductField.LABELS_TAGS_TRANSLATED) ||
configuration.fields.contains(ProductField.ALL)) {
result.products.asMap().forEach((index, product) {
ProductHelper.removeImages(product, configuration.language);
ProductHelper.addTranslatedFields(product,
result.jsonProducts.elementAt(index), configuration.language); // USED HERE !!!!!!!!!
});
} else {
result.products.asMap().forEach((index, product) {
ProductHelper.removeImages(product, configuration.language);
});
}
return result;
} |
A zoom on static void addTranslatedFields(Product product, Map<String, dynamic> source,
OpenFoodFactsLanguage language) {
product.categoriesTagsTranslated =
source['categories_tags_${language.code}'];
product.labelsTagsTranslated = source['labels_tags_${language.code}'];
} The idea seems to be: only if some flags are set ( |
Thanks for looking into this. Yes, that would be much better than storing all the products twice. |
Of course I could easily add that @peterwvj Could you add (and populate) that |
Feel free to remove the annotation from |
@peterwvj The action must be more specifically on |
Okay, thanks for clarifying. |
@peterwvj Json annotations are unfortunately:
We'll still enjoy json annotations for other classes, and we'll use what json annotations generated for |
That's fine. By all means remove it if everyone else agrees. It's not that I'm a fan of json_serializable I'm just pointing out a significant cost of not using it. I always felt that JSON conversion is a bit awkward in Dart as compared to languages that support reflection. |
fix_3/#90 - support of relative files in UriReader
… for SearchResult Impacted files: * `openfoodfacts.dart`: removed any reference to translated fields, that are now automatically computed * `Product.dart`: automatically computed the translated categories and labels * `ProductHelper.dart`: deprecated the method to translate fields, which is automatic now * `SearchResult.dart`: removed the confusing and space-consuming raw `jsonProducts` field; let the `fromJson` method point to the json annotation generated method * `SearchResult.g.dart`: removed the confusing and space-consuming raw `jsonProducts` field
fix_4/#90 - better space management and code readability for SearchResult
I've just run
|
@monsieurtanuki a great job was done there thanks, and it is a huge improvement for the score. |
I agree with you @MohamedFBoussaid, no rush. |
I just updated the packages to the newest version #98. |
On the way to a 130/130 pub.dev score... Impacted files: * `ContainsAdditives.dart`: added a comment on class; refactored as non-nullable * `OutputFormat.dart`: added a comment on class and enum; refactored * `Page.dart`: added a comment on class; refactored as non-nullable * `PageSize.dart`: added a comment on class; refactored as non-nullable * `Parameter.dart`: added a comment on class; created method `addToMap` * `ProductSearchQueryConfiguration.dart`: added a comment on class; refactored some fields as non-nullable * `SearchSimple.dart`: not done much as the purpose of the class is unclear * `SearchTerms.dart`: added a comment on class; refactored as non-nullable * `SortBy.dart`: added a comment on class and enum; refactored * `TagFilter.dart`: added a comment on class and enum; overridden new method `addToMap`; refactored
I've just rolled back changes I made that actually added complexity without added value. Impacted files: * `Parameter.dart` * `ProductSearchQueryConfiguration.dart` * `TagFilter.dart`
fix_5/#90 - added comments to Parameter-related classes
…der "utils" There are still classes to add comments to in this folder, but this is a quick PR. Impacted files: * `ImageHelper.dart` * `JsonHelper.dart` * `LanguageHelper.dart` * `NutrimentsHelper.dart` * `PnnsGroupQueryConfiguration.dart` * `PnnsGroups.dart` * `ProductFields.dart` * `ProductHelper.dart` * `QueryType.dart` * `UnitHelper.dart`
fix_6/#90 - added comments to classes and methods in folder "utils"
Version 1.3.0 - still some work to be done for a score of 130/130:
|
I don't know how In order to exceed the 20% threshold, I'm going to be lazy and just comment stupidly the languages (186) and the nutrients (170): we should reach around 28% of comments, and we'll get the 130/130 score. Hopefully... |
…r pub.dev Impacted files: * `api_getProduct_test.dart`: added a test about the fix on alcohol * `LanguageHelper.dart`: commented individually each language * `Nutriments.dart`: fixed alcohol tags; commented individually each field * `Nutriments.g.dart`: (generated) fixed alcohol tags
fix_7/#90 - fixed alcohol tags; added enough comments for pub.dev
We did it, we reached the 130/130 score 🥇 Thanks @monsieurtanuki for your provided mass documentation, we reached a stunning 46.7 % coverage |
Wonderful! Well, it took about 8 PRs to go from 80 to 130 points. I guess now we have enough code stability to stay at 130. |
The current version has the following score
Maybe we can improve the score, by following pub.dev recommandations.
The text was updated successfully, but these errors were encountered: