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

Move remaining helper functions to lib/ #1109

Merged
merged 8 commits into from
Oct 2, 2017
Merged

Move remaining helper functions to lib/ #1109

merged 8 commits into from
Oct 2, 2017

Conversation

paulmelnikow
Copy link
Member

  • Clear the regular update cache between unit tests

- Clear the regular update cache between unit tests
@paulmelnikow paulmelnikow added the core Server, BaseService, GitHub auth, Shared helpers label Sep 28, 2017
Copy link
Member

@Daniel15 Daniel15 left a comment

Choose a reason for hiding this comment

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

This looks pretty good to me. Thank you!

return version.match(pattern);
} else {
return false;
}
Copy link
Member

Choose a reason for hiding this comment

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

This could just do `return !!version && version.match(pattern);


module.exports = {
isNexusSnapshotVersion
};
Copy link
Member

Choose a reason for hiding this comment

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

Maybe call this module nexus-version rather than nexus-snapshot-version

}

module.exports = {
isNexusSnapshotVersion
Copy link
Member

Choose a reason for hiding this comment

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

Just call this isSnapshotVersion, since "nexus" is redundant (it's already in the module name)

module.exports = {
mapNugetFeedv2,
mapNugetFeed
};
Copy link
Member

Choose a reason for hiding this comment

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

Maybe call these "providers" and make a providers directory for them? "helpers" doesn't really fully describe what these functions do, since they actually serve the badges (so they're not just helpers).

Copy link
Member Author

@paulmelnikow paulmelnikow Oct 2, 2017

Choose a reason for hiding this comment

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

Right, it's true that they're not helpers.

I think #963 is a much better approach for refactoring services. I don't want to fortify or encourage this approach, and feel like making a folder would do that. How about I rename them from -badge-helpers to -provider?

Copy link
Member

Choose a reason for hiding this comment

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

That sounds good to me! I'll revive #963 soon, when I have a bit more free time :)


// Map from URL to { timestamp: last fetch time, interval: in milliseconds,
// data: data }.
let regularUpdateCache = Object.create(null);
Copy link
Member

Choose a reason for hiding this comment

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

I think we're on a new enough version of Node to use Map here, rather than an "object as a map".


function makeSend(format, askres, end) {
if (format === 'svg') {
return function(res) { sendSVG(res, askres, end); };
Copy link
Member

Choose a reason for hiding this comment

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

Use an arrow function:

return res => sendSVG(res, askres, end);

@paulmelnikow
Copy link
Member Author

Thanks for reviewing!

None of this is new code, and I prefer to avoid making changes as code is moved, since the changes are impossible to discern in the commit history.

I'll update the names, and open a new PR for the rest!

@paulmelnikow
Copy link
Member Author

Nexus service tests are not passing locally, though the Nexus failure exists in e2ee910, when the code entered, so it's not related to this change. Also failing are github and amo, also unrelated.

@paulmelnikow paulmelnikow merged commit c62534b into badges:master Oct 2, 2017
@paulmelnikow paulmelnikow deleted the last-helpers branch October 2, 2017 02:08
paulmelnikow added a commit that referenced this pull request Oct 6, 2017
Address comments from #1109 and make several code-quality fixes which were caught by a local run of eslint-config-standard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Server, BaseService, GitHub auth, Shared helpers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants