Skip to content

Commit

Permalink
Auto merge of #6777 - frewsxcv:refactor-tidy, r=jdm
Browse files Browse the repository at this point in the history
Cleanup lint special cases, refactor flake8 linting 

Currently, there are a few linting functions that only run on certain
filetypes (determined by the file extension). Prior to this commit, the
special cases were handled in a parent function with a conditional. This
commit changes the system so each linting function gets passed a
filename so the function can determine whether it should run or not
based on the file extension.

I also refactored flake8 linting slightly. From what I've read so far of
the code, flake8 itself will only print the results directly to stdout
(though the linter would report the quantity of errors detected).
Prior to this commit, we would let flake8 print directly to stdout and
just determine if there were >0 errors reported. This commit (sort of
hackily) temporarily captures stdout when we call flake8 so we can do
what we want with the output, allowing us to `yield` the line number
and message like we do with the other linting functions.

In my opinion, both of these changes isolate specific behaviors/checks
into their respective linting functions instead of having them handled
at a more global level.

In addition to the changes above:

* The whitespace linter now runs on WebIDL and TOML files
* The license header linter now runs on WebIDL files

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6777)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Jul 27, 2015
2 parents 78455ec + 9e5f31c commit 7c8922c
Show file tree
Hide file tree
Showing 71 changed files with 271 additions and 202 deletions.
6 changes: 3 additions & 3 deletions components/script/dom/webidls/Attr.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is
* https://dom.spec.whatwg.org/#interface-attr
*
Expand Down
3 changes: 2 additions & 1 deletion components/script/dom/webidls/Blob.webidl
Expand Up @@ -5,7 +5,8 @@

// http://dev.w3.org/2006/webapi/FileAPI/#dfn-Blob
//[Exposed=Window,Worker][Constructor,
// Constructor(sequence<(ArrayBuffer or ArrayBufferView or Blob or DOMString)> blobParts, optional BlobPropertyBag options)]
// Constructor(sequence<(ArrayBuffer or ArrayBufferView or Blob or DOMString)> blobParts,
// optional BlobPropertyBag options)]
[Constructor,
Constructor(DOMString blobParts, optional BlobPropertyBag options)]
interface Blob {
Expand Down
5 changes: 2 additions & 3 deletions components/script/dom/webidls/BrowserElement.webidl
@@ -1,8 +1,7 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API

Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/webidls/CSS.webidl
@@ -1,7 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is
* http://dev.w3.org/csswg/cssom/#the-css-interface
*/
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/webidls/CSSStyleDeclaration.webidl
@@ -1,7 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is
* http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface
*
Expand Down
34 changes: 23 additions & 11 deletions components/script/dom/webidls/CanvasRenderingContext2D.webidl
Expand Up @@ -94,14 +94,18 @@ interface CanvasRenderingContext2D {
void clip(optional CanvasWindingRule fillRule = "nonzero");
//void clip(Path2D path, optional CanvasWindingRule fillRule = "nonzero");
//void resetClip();
//boolean isPointInPath(unrestricted double x, unrestricted double y, optional CanvasWindingRule fillRule = "nonzero");
//boolean isPointInPath(Path2D path, unrestricted double x, unrestricted double y, optional CanvasWindingRule fillRule = "nonzero");
//boolean isPointInPath(unrestricted double x, unrestricted double y,
// optional CanvasWindingRule fillRule = "nonzero");
//boolean isPointInPath(Path2D path, unrestricted double x, unrestricted double y,
// optional CanvasWindingRule fillRule = "nonzero");
//boolean isPointInStroke(unrestricted double x, unrestricted double y);
//boolean isPointInStroke(Path2D path, unrestricted double x, unrestricted double y);

// text (see also the CanvasDrawingStyles interface)
//void fillText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
//void strokeText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
//void fillText(DOMString text, unrestricted double x, unrestricted double y,
// optional unrestricted double maxWidth);
//void strokeText(DOMString text, unrestricted double x, unrestricted double y,
// optional unrestricted double maxWidth);
//TextMetrics measureText(DOMString text);

// drawing images
Expand All @@ -128,7 +132,10 @@ interface CanvasRenderingContext2D {
[Throws]
ImageData getImageData(double sx, double sy, double sw, double sh);
void putImageData(ImageData imagedata, double dx, double dy);
void putImageData(ImageData imagedata, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight);
void putImageData(ImageData imagedata,
double dx, double dy,
double dirtyX, double dirtyY,
double dirtyWidth, double dirtyHeight);
};

[NoInterfaceObject]
Expand All @@ -147,7 +154,8 @@ interface CanvasDrawingStyles {
// text
//attribute DOMString font; // (default 10px sans-serif)
//attribute DOMString textAlign; // "start", "end", "left", "right", "center" (default: "start")
//attribute DOMString textBaseline; // "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" (default: "alphabetic")
//attribute DOMString textBaseline; // "top", "hanging", "middle", "alphabetic",
// "ideographic", "bottom" (default: "alphabetic")
//attribute DOMString direction; // "ltr", "rtl", "inherit" (default: "inherit")
};

Expand All @@ -157,7 +165,8 @@ interface CanvasPathMethods {
void closePath();
void moveTo(unrestricted double x, unrestricted double y);
void lineTo(unrestricted double x, unrestricted double y);
void quadraticCurveTo(unrestricted double cpx, unrestricted double cpy, unrestricted double x, unrestricted double y);
void quadraticCurveTo(unrestricted double cpx, unrestricted double cpy,
unrestricted double x, unrestricted double y);

void bezierCurveTo(unrestricted double cp1x,
unrestricted double cp1y,
Expand All @@ -170,16 +179,19 @@ interface CanvasPathMethods {
void arcTo(unrestricted double x1, unrestricted double y1,
unrestricted double x2, unrestricted double y2,
unrestricted double radius);
// NOT IMPLEMENTED [LenientFloat] void arcTo(double x1, double y1, double x2, double y2, double radiusX, double radiusY, double rotation);
// [LenientFloat] void arcTo(double x1, double y1, double x2, double y2,
// double radiusX, double radiusY, double rotation);

void rect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);

[Throws]
void arc(double x, double y, double radius, double startAngle, double endAngle, optional boolean anticlockwise = false);
// NOT IMPLEMENTED [LenientFloat] void ellipse(double x, double y, double radiusX, double radiusY, double rotation, double startAngle, double endAngle, boolean anticlockwise);
void arc(double x, double y, double radius, double startAngle, double endAngle,
optional boolean anticlockwise = false);
// [LenientFloat] void ellipse(double x, double y, double radiusX, double radiusY,
// double rotation, double startAngle, double endAngle,
// boolean anticlockwise);
};


CanvasRenderingContext2D implements CanvasDrawingStyles;
CanvasRenderingContext2D implements CanvasPathMethods;

6 changes: 3 additions & 3 deletions components/script/dom/webidls/CharacterData.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is
* https://dom.spec.whatwg.org/#characterdata
*
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/webidls/ChildNode.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is:
* https://dom.spec.whatwg.org/#interface-childnode
*/
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/webidls/Comment.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is
* https://dom.spec.whatwg.org/#comment
*
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/webidls/Console.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* References:
* MDN Docs - https://developer.mozilla.org/en-US/docs/Web/API/console
* Draft Spec - https://sideshowbarker.github.io/console-spec/
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/webidls/Crypto.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is
* https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#crypto-interface
*
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/webidls/CustomEvent.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* For more information on this interface please see
* https://dom.spec.whatwg.org/#interface-customevent
*
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/webidls/DOMException.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is:
* https://dom.spec.whatwg.org/#domexception
*/
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/webidls/DOMImplementation.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is
* https://dom.spec.whatwg.org/#interface=domimplementation
*
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/webidls/DOMParser.webidl
@@ -1,7 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is
* https://domparsing.spec.whatwg.org/#the-domparser-interface
*/
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/webidls/DOMPoint.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is
* http://dev.w3.org/fxtf/geometry/
*
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/webidls/DOMPointReadOnly.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is
* http://dev.w3.org/fxtf/geometry/
*
Expand Down
12 changes: 7 additions & 5 deletions components/script/dom/webidls/Document.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is:
* https://dom.spec.whatwg.org/#interface-document
* https://www.whatwg.org/specs/web-apps/current-work/#the-document-object
Expand Down Expand Up @@ -59,9 +59,11 @@ interface Document : Node {

// NodeFilter.SHOW_ALL = 0xFFFFFFFF
[NewObject]
NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF,
optional NodeFilter? filter = null);
[NewObject]
TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF,
optional NodeFilter? filter = null);
};
Document implements ParentNode;

Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/webidls/DocumentType.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is
* https://dom.spec.whatwg.org/#documenttype
*
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/webidls/Element.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is
* https://dom.spec.whatwg.org/#element and
* https://domparsing.spec.whatwg.org/ and
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/webidls/ErrorEvent.webidl
Expand Up @@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// https://html.spec.whatwg.org/multipage/#the-errorevent-interface
// https://html.spec.whatwg.org/multipage/#the-errorevent-interface

[Constructor(DOMString type, optional ErrorEventInit eventInitDict)/*, Exposed=(Window,Worker)*/]
interface ErrorEvent : Event {
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/webidls/Event.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* For more information on this interface please see
* http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html
*
Expand Down
10 changes: 6 additions & 4 deletions components/script/dom/webidls/EventHandler.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is
* https://www.whatwg.org/specs/web-apps/current-work/#eventhandler
*
Expand All @@ -16,7 +16,9 @@ callback EventHandlerNonNull = any (Event event);
typedef EventHandlerNonNull? EventHandler;

[TreatNonObjectAsNull]
callback OnErrorEventHandlerNonNull = boolean ((Event or DOMString) event, optional DOMString source, optional unsigned long lineno, optional unsigned long column, optional any error);
callback OnErrorEventHandlerNonNull = boolean ((Event or DOMString) event, optional DOMString source,
optional unsigned long lineno, optional unsigned long column,
optional any error);
typedef OnErrorEventHandlerNonNull? OnErrorEventHandler;

[NoInterfaceObject]
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/webidls/EventListener.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* https://dom.spec.whatwg.org/#callbackdef-eventlistener
*/

Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/webidls/EventTarget.webidl
@@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* https://dom.spec.whatwg.org/#interface-eventtarget
*/

Expand Down
5 changes: 2 additions & 3 deletions components/script/dom/webidls/FileReader.webidl
@@ -1,8 +1,7 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// http://dev.w3.org/2006/webapi/FileAPI/#APIASynch

Expand Down

0 comments on commit 7c8922c

Please sign in to comment.