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

Do not use arguments object #3102

Merged
merged 6 commits into from
Apr 10, 2018
Merged

Do not use arguments object #3102

merged 6 commits into from
Apr 10, 2018

Conversation

segayuu
Copy link
Contributor

@segayuu 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 March 30, 2018 04:30
@coveralls
Copy link

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
Copy link

Coverage Status

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

@coveralls
Copy link

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 No use arguments Do not use arguments object Apr 2, 2018
@segayuu segayuu requested review from a team and removed request for tommy351 April 6, 2018 04:05
Copy link

@demurgos demurgos left a comment

Choose a reason for hiding this comment

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

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) => {
Copy link

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

\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');
Copy link

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@demurgos
Copy link

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 segayuu requested a review from a team April 9, 2018 01:08
@JLHwung JLHwung merged commit 106980e into hexojs:master Apr 10, 2018
@segayuu segayuu deleted the no-use-arguments branch April 10, 2018 06:17
thom4parisot pushed a commit to thom4parisot/hexo that referenced this pull request Jan 17, 2020
* refactor: split function

* lodash.toArray to rest param

* remove arguments

* no use arguments

* fix param

* forTag.compile() does not use thisArg.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants