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

Unify indentation and add .editorconfig #973

Merged
merged 1 commit into from Apr 13, 2017
Merged

Unify indentation and add .editorconfig #973

merged 1 commit into from Apr 13, 2017

Conversation

mathiasbynens
Copy link
Member

@mathiasbynens mathiasbynens commented Apr 13, 2017

Many different coding styles are being used across the various non-test files in this repository.

  • For Python files, four-space indentation (per PEP 8) seemed to be the most common. However, some files were using two-space. I’ve changed them to use four spaces and codified this preference in .editorconfig.
  • For JavaScript files, most of the tests, as well as most non-test files seemed to be using two-space indents. However, some files were using four-space indents, five-space indents (!), and a single file was using tabs. I’ve changed them to use two spaces and codified this preference in .editorconfig.

While going through the files, I noticed something odd. The indentation seems to imply that a brace is missing here:

if (!predicate(current)) {
while (!predicate(current))
current = new Date(current.getTime() + step);
current = new Date(current.getTime() - step);
}
This patch adds that brace — let me know if it shouldn’t be there, in which case I’ll fix the indentation.

Diff sans whitespace changes: https://github.com/tc39/test262/pull/973/files?w=1

@leobalter
Copy link
Member

This is great!

For more information, I asked @mathiasbynens to help with this and I believe applying a few whitespace style rules will be great.

@leobalter leobalter merged commit a621155 into tc39:master Apr 13, 2017
@anba
Copy link
Contributor

anba commented Apr 13, 2017

While going through the files, I noticed something odd. The indentation seems to imply that a brace is missing here:

if (!predicate(current)) {
while (!predicate(current))
current = new Date(current.getTime() + step);
current = new Date(current.getTime() - step);
}
This patch adds that brace — let me know if it shouldn’t be there, in which case I’ll fix the indentation.

The brace was added at the wrong location, which results in an iloop when executing the file. But instead of fixing this, let's just remove everything from the file which isn't actually needed for test262:

// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
//the following values are normally generated by the sputnik.py driver
var $LocalTZ,
$DST_start_month,
$DST_start_sunday,
$DST_start_hour,
$DST_start_minutes,
$DST_end_month,
$DST_end_sunday,
$DST_end_hour,
$DST_end_minutes;
(function () {
/**
* Finds the first date, starting from |start|, where |predicate|
* holds.
*/
var findNearestDateBefore = function(start, predicate) {
var current = start;
var month = 1000 * 60 * 60 * 24 * 30;
for (var step = month; step > 0; step = Math.floor(step / 3)) {
if (!predicate(current)) {
while (!predicate(current)) {
current = new Date(current.getTime() + step);
current = new Date(current.getTime() - step);
}
}
}
while (!predicate(current)) {
current = new Date(current.getTime() + 1);
}
return current;
};
var juneDate = new Date(2000, 5, 20, 0, 0, 0, 0);
var decemberDate = new Date(2000, 11, 20, 0, 0, 0, 0);
var juneOffset = juneDate.getTimezoneOffset();
var decemberOffset = decemberDate.getTimezoneOffset();
var isSouthernHemisphere = (juneOffset > decemberOffset);
var winterTime = isSouthernHemisphere ? juneDate : decemberDate;
var summerTime = isSouthernHemisphere ? decemberDate : juneDate;
var dstStart = findNearestDateBefore(winterTime, function (date) {
return date.getTimezoneOffset() == summerTime.getTimezoneOffset();
});
$DST_start_month = dstStart.getMonth();
$DST_start_sunday = dstStart.getDate() > 15 ? '"last"' : '"first"';
$DST_start_hour = dstStart.getHours();
$DST_start_minutes = dstStart.getMinutes();
var dstEnd = findNearestDateBefore(summerTime, function (date) {
return date.getTimezoneOffset() == winterTime.getTimezoneOffset();
});
$DST_end_month = dstEnd.getMonth();
$DST_end_sunday = dstEnd.getDate() > 15 ? '"last"' : '"first"';
$DST_end_hour = dstEnd.getHours();
$DST_end_minutes = dstEnd.getMinutes();
return;
})();

@mathiasbynens
Copy link
Member Author

mathiasbynens commented Apr 13, 2017

@anba Good catch. Could you please submit a PR for that change?

Update: #975


[{README.md,package.json,.travis.yml,*.sh,*.js}]
indent_style = space
indent_size = 2
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

@rwaldron
Copy link
Contributor

Makes me so happy.

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.

None yet

4 participants