From 6f8d33fe11fbfb5f721a1989d18fbd82a4554b72 Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Thu, 24 Dec 2015 10:26:48 +0501 Subject: [PATCH] servo: Merge #9055 - Issue #9042: Report incorrect number of spaces around => in the style checker (from simartin:issue_9042); r=Wafflespeanut Fixes https://github.com/servo/servo/issues/9042 Source-Repo: https://github.com/servo/servo Source-Revision: f77c7928868469ef4f326a269147ae2aee6151ee --- .../devtools/actors/network_event.rs | 6 +-- servo/components/gfx/paint_context.rs | 6 +-- .../components/layout/display_list_builder.rs | 2 +- servo/components/script/dom/document.rs | 52 +++++++++---------- .../components/script/dom/htmlformelement.rs | 2 +- servo/components/util/debug_utils.rs | 2 +- servo/python/tidy.py | 16 ++++-- 7 files changed, 48 insertions(+), 38 deletions(-) diff --git a/servo/components/devtools/actors/network_event.rs b/servo/components/devtools/actors/network_event.rs index 317dc096157e..eb77f174a9d7 100644 --- a/servo/components/devtools/actors/network_event.rs +++ b/servo/components/devtools/actors/network_event.rs @@ -359,7 +359,7 @@ impl NetworkEventActor { let mut mString = "".to_owned(); if let Some(ref headers) = self.response.headers { mString = match headers.get() { - Some(&ContentType(ref mime)) => mime.to_string(), + Some(&ContentType(ref mime)) => mime.to_string(), None => "".to_owned() }; } @@ -377,7 +377,7 @@ impl NetworkEventActor { let mut cookies_size = 0; if let Some(ref headers) = self.response.headers { cookies_size = match headers.get() { - Some(&Cookie(ref cookie)) => cookie.len(), + Some(&Cookie(ref cookie)) => cookie.len(), None => 0 }; } @@ -408,7 +408,7 @@ impl NetworkEventActor { let mut cookies_size = 0; if let Some(ref headers) = self.response.headers { cookies_size = match headers.get() { - Some(&Cookie(ref cookie)) => cookie.len(), + Some(&Cookie(ref cookie)) => cookie.len(), None => 0 }; } diff --git a/servo/components/gfx/paint_context.rs b/servo/components/gfx/paint_context.rs index 0000c62f0caf..1270071825de 100644 --- a/servo/components/gfx/paint_context.rs +++ b/servo/components/gfx/paint_context.rs @@ -1251,9 +1251,9 @@ impl<'a> PaintContext<'a> { 0.5 * border.bottom, 0.5 * border.left); let is_groove = match style { - border_style::T::groove => true, - border_style::T::ridge => false, - _ => panic!("invalid border style") + border_style::T::groove => true, + border_style::T::ridge => false, + _ => panic!("invalid border style") }; let lighter_color; diff --git a/servo/components/layout/display_list_builder.rs b/servo/components/layout/display_list_builder.rs index 7370723a4df7..7cc1d3f63114 100644 --- a/servo/components/layout/display_list_builder.rs +++ b/servo/components/layout/display_list_builder.rs @@ -1137,7 +1137,7 @@ impl FragmentDisplayListBuilding for Fragment { if width > 0 && height > 0 { let layer_id = self.layer_id(); let canvas_data = match canvas_fragment_info.ipc_renderer { - Some(ref ipc_renderer) => { + Some(ref ipc_renderer) => { let ipc_renderer = ipc_renderer.lock().unwrap(); let (sender, receiver) = ipc::channel().unwrap(); ipc_renderer.send(CanvasMsg::FromLayout( diff --git a/servo/components/script/dom/document.rs b/servo/components/script/dom/document.rs index d1e529f3bfa4..6fe811ef1680 100644 --- a/servo/components/script/dom/document.rs +++ b/servo/components/script/dom/document.rs @@ -381,32 +381,32 @@ impl Document { pub fn set_encoding_name(&self, name: DOMString) { *self.encoding_name.borrow_mut() = DOMString::from( match name.as_ref() { - "utf-8" => "UTF-8", - "ibm866" => "IBM866", - "iso-8859-2" => "ISO-8859-2", - "iso-8859-3" => "ISO-8859-3", - "iso-8859-4" => "ISO-8859-4", - "iso-8859-5" => "ISO-8859-5", - "iso-8859-6" => "ISO-8859-6", - "iso-8859-7" => "ISO-8859-7", - "iso-8859-8" => "ISO-8859-8", - "iso-8859-8-i" => "ISO-8859-8-I", - "iso-8859-10" => "ISO-8859-10", - "iso-8859-13" => "ISO-8859-13", - "iso-8859-14" => "ISO-8859-14", - "iso-8859-15" => "ISO-8859-15", - "iso-8859-16" => "ISO-8859-16", - "koi8-r" => "KOI8-R", - "koi8-u" => "KOI8-U", - "gbk" => "GBK", - "big5" => "Big5", - "euc-jp" => "EUC-JP", - "iso-2022-jp" => "ISO-2022-JP", - "shift_jis" => "Shift_JIS", - "euc-kr" => "EUC-KR", - "utf-16be" => "UTF-16BE", - "utf-16le" => "UTF-16LE", - _ => &*name + "utf-8" => "UTF-8", + "ibm866" => "IBM866", + "iso-8859-2" => "ISO-8859-2", + "iso-8859-3" => "ISO-8859-3", + "iso-8859-4" => "ISO-8859-4", + "iso-8859-5" => "ISO-8859-5", + "iso-8859-6" => "ISO-8859-6", + "iso-8859-7" => "ISO-8859-7", + "iso-8859-8" => "ISO-8859-8", + "iso-8859-8-i" => "ISO-8859-8-I", + "iso-8859-10" => "ISO-8859-10", + "iso-8859-13" => "ISO-8859-13", + "iso-8859-14" => "ISO-8859-14", + "iso-8859-15" => "ISO-8859-15", + "iso-8859-16" => "ISO-8859-16", + "koi8-r" => "KOI8-R", + "koi8-u" => "KOI8-U", + "gbk" => "GBK", + "big5" => "Big5", + "euc-jp" => "EUC-JP", + "iso-2022-jp" => "ISO-2022-JP", + "shift_jis" => "Shift_JIS", + "euc-kr" => "EUC-KR", + "utf-16be" => "UTF-16BE", + "utf-16le" => "UTF-16LE", + _ => &*name }); } diff --git a/servo/components/script/dom/htmlformelement.rs b/servo/components/script/dom/htmlformelement.rs index 6515eb584718..a8f9ce28db5a 100644 --- a/servo/components/script/dom/htmlformelement.rs +++ b/servo/components/script/dom/htmlformelement.rs @@ -464,7 +464,7 @@ pub enum FormSubmittableElement { impl FormSubmittableElement { fn as_event_target(&self) -> &EventTarget { match *self { - FormSubmittableElement::ButtonElement(ref button) => button.r().upcast(), + FormSubmittableElement::ButtonElement(ref button) => button.r().upcast(), FormSubmittableElement::InputElement(ref input) => input.r().upcast(), FormSubmittableElement::ObjectElement(ref object) => object.r().upcast(), FormSubmittableElement::SelectElement(ref select) => select.r().upcast(), diff --git a/servo/components/util/debug_utils.rs b/servo/components/util/debug_utils.rs index 8c1954c78ba7..631c7dad4ca2 100644 --- a/servo/components/util/debug_utils.rs +++ b/servo/components/util/debug_utils.rs @@ -15,7 +15,7 @@ fn hexdump_slice(buf: &[u8]) { stderr.write_all(output.as_bytes()).unwrap(); match i % 16 { 15 => { stderr.write_all(b"\n ").unwrap(); }, - 7 => { stderr.write_all(b" ").unwrap(); }, + 7 => { stderr.write_all(b" ").unwrap(); }, _ => () } stderr.flush().unwrap(); diff --git a/servo/python/tidy.py b/servo/python/tidy.py index d974a89a1b8b..d1a10522d4af 100644 --- a/servo/python/tidy.py +++ b/servo/python/tidy.py @@ -314,6 +314,16 @@ def check_rust(file_name, contents): if match: yield (idx + 1, "missing space after ->") + line_len = len(line) + arrow_pos = line.find("=>") + if arrow_pos != -1: + if arrow_pos and line[arrow_pos - 1] != ' ': + yield (idx + 1, "missing space before =>") + if arrow_pos + 2 < line_len and line[arrow_pos + 2] != ' ': + yield (idx + 1, "missing space after =>") + elif arrow_pos + 3 < line_len and line[arrow_pos + 3] == ' ': + yield (idx + 1, "extra space after =>") + # Avoid flagging ::crate::mod and `trait Foo : Bar` match = line.find(" :") if match != -1: @@ -344,7 +354,7 @@ def check_rust(file_name, contents): # check extern crates if line.startswith("extern crate "): crate_name = line[len("extern crate "):-1] - indent = len(original_line) - len(line) + indent = len(original_line) - line_len if indent not in prev_crate: prev_crate[indent] = "" if prev_crate[indent] > crate_name: @@ -358,7 +368,7 @@ def check_rust(file_name, contents): elif line.startswith("use "): import_block = True use = line[4:] - indent = len(original_line) - len(line) + indent = len(original_line) - line_len if not use.endswith(";"): yield (idx + 1, "use statement spans multiple lines") current_use = use[:len(use) - 1] @@ -378,7 +388,7 @@ def check_rust(file_name, contents): # modules must be in the same line and alphabetically sorted if line.startswith("mod ") or line.startswith("pub mod "): - indent = len(original_line) - len(line) + indent = len(original_line) - line_len mod = line[4:] if line.startswith("mod ") else line[8:] if idx < 0 or "#[macro_use]" not in contents[idx - 1]: