Skip to content

Validate workspace recommended extensions against the marketplace#40270

Merged
ramya-rao-a merged 5 commits intomicrosoft:masterfrom
sbatten:users/stbatt/wsextrec
Dec 19, 2017
Merged

Validate workspace recommended extensions against the marketplace#40270
ramya-rao-a merged 5 commits intomicrosoft:masterfrom
sbatten:users/stbatt/wsextrec

Conversation

@sbatten
Copy link
Member

@sbatten sbatten commented Dec 15, 2017

Don't show message about workspace recommended extensions if none of the recommended extensions are valid (i.e. they are badly formatted or don't exist in the marketplace)

Copy link
Contributor

@ramya-rao-a ramya-rao-a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is scope for a few improvements. Take a look.

});

if (filteredRecommendations.length !== extensionsContent.recommendations.length) {
let badlyFormattedRecommendations = extensionsContent.recommendations.filter(element => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of looping through extensionsContent.recommendations one more time here, you can use the callback for the extensionsContent.recommendations.filter to find the badly formatted recommendations and form the badRecommendationsString

return extensionsContent.recommendations.indexOf(element) === position && regEx.test(element);
});

if (filteredRecommendations.length !== extensionsContent.recommendations.length) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition will pass if there are duplicate valid recommendations as well

});

let unknownExtensionsString = '';
unknownExtensions.forEach(element => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why loop one more time, when you can use the callback for filteredRecommendations.filter to form the unknownExtensionsString

});

console.log(unknownExtensions.length +
' extension(s) in workspace recommendations were not found in the gallery:\n' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Prefix this message with The below . Same for the other message

badlyFormattedRecommendations.forEach(element => {
badRecommendationsString += element + '\n';
});
if (!regEx.test(element)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way if there is a recommendation not following the regex appearing twice, then it will appear in the badRecommendationsString twice.

Duplication in recommendations doesn't cause any harm. We don't need to add a warning for it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fixing this to only log once per distinct value as recommended. However, the reason I was in favor of logging duplicates is specifically for when the author has duplicate bad entries. They will see they have a bad entry, fix it, then see the exact same error logging and possibly be very confused if their changes were picked up. I could check to see if a bad entry is a duplicate (using lastIndexOf, and log as (bad format, duplicate)

filteredRecommendations.forEach(element => {
if (validRecommendations.indexOf(element.toLowerCase()) === -1) {
countBadRecommendations++;
badRecommendationsString += `${element} (not found in gallery)\n`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the word marketplace instead of gallery. I know, its called the gallery service, but the website users can go search for extension is called marketplace (powered by the same gallery service :) )

@ramya-rao-a ramya-rao-a merged commit 674fd2e into microsoft:master Dec 19, 2017
@ramya-rao-a ramya-rao-a added this to the January 2018 milestone Feb 2, 2018
@sbatten sbatten deleted the users/stbatt/wsextrec branch September 18, 2018 18:02
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants