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

Do not use arguments object #3102

Merged
merged 6 commits into from Apr 10, 2018

Conversation

4 participants
@segayuu
Contributor

segayuu commented Mar 30, 2018

Thank you for creating a pull request to contribute to Hexo code! Before you open the request please review the following guidelines and tips to help it be more easily integrated:

  • Add test cases for the changes.
  • Passed the CI test.

@segayuu segayuu requested a review from tommy351 Mar 30, 2018

@coveralls

This comment has been minimized.

coveralls commented Mar 30, 2018

Coverage Status

Coverage decreased (-0.05%) to 97.213% when pulling 9f51f9d on segayuu:no-use-arguments into a846bbd on hexojs:master.

1 similar comment
@coveralls

This comment has been minimized.

coveralls commented Mar 30, 2018

Coverage Status

Coverage decreased (-0.05%) to 97.213% when pulling 9f51f9d on segayuu:no-use-arguments into a846bbd on hexojs:master.

@coveralls

This comment has been minimized.

coveralls commented Mar 30, 2018

Coverage Status

Coverage decreased (-0.05%) to 97.213% when pulling 488395b on segayuu:no-use-arguments into a846bbd on hexojs:master.

@segayuu segayuu changed the title from No use arguments to Do not use arguments object Apr 2, 2018

@segayuu segayuu requested review from hexojs/core and removed request for tommy351 Apr 6, 2018

@demurgos

Rest parameters are available by default in Node 6 and above so there should be no issue with the versions supported by Hexo.
I added some other comments but overall it's a good change. Thanks.

I'd still would prefer others to check this PR.

const end = arguments[5];
const args = arguments[3].split('=').shift();
let content = arguments[4];
data.content = data.content.replace(rBacktick, ($0, start, $2, _args, content, end) => {

This comment has been minimized.

@demurgos

demurgos Apr 6, 2018

Member

It would be better to use non-capturing groups (?: ) in the regular expressions to avoid unused arguments.

This comment has been minimized.

@segayuu

segayuu Apr 6, 2018

Contributor

\2 is used in the RegExp literal and can not be deleted with node v6.
const rBacktick = /(\s*)(`{3,}|~{3,}) *(.*) *\n([\s\S]+?)\s*\2(\n+|$)/g;

swig.setTag('for', forTag.parse, function(compiler, args, content, parents, options, blockName) {
const compile = forTag.compile.apply(this, arguments).split('\n');
swig.setTag('for', forTag.parse, function(...args) {
const compile = forTag.compile.apply(this, args).split('\n');

This comment has been minimized.

@demurgos

demurgos Apr 6, 2018

Member

Is the thisArg used in forTag.compile? If no, it could be simplified to forTag.compile(...args).split('\n')

This comment has been minimized.

@segayuu

segayuu Apr 6, 2018

Contributor

I do not know if the value of this in the callback of swig.setTag() and the value of this in forTag.compile() do not know whether it works correctly or not.

This comment has been minimized.

@segayuu
@demurgos

This comment has been minimized.

Member

demurgos commented Apr 6, 2018

So, I tracked the relevant Node versions and I confirm it's fine. Rest parameters are supported since Node 6.

segayuu added some commits Apr 6, 2018

@segayuu segayuu requested a review from hexojs/core Apr 9, 2018

@JLHwung JLHwung merged commit 106980e into hexojs:master Apr 10, 2018

2 of 4 checks passed

codeclimate 7 issues to fix
Details
coverage/coveralls Coverage decreased (-0.05%) to 97.213%
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@segayuu segayuu deleted the segayuu:no-use-arguments branch Apr 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment