Skip to content

Commit

Permalink
Make test-tidy check that braces have spaces before or after them
Browse files Browse the repository at this point in the history
  • Loading branch information
wilcus committed Aug 31, 2015
1 parent aee011a commit 64ac4f1
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 21 deletions.
4 changes: 2 additions & 2 deletions components/gfx/text/shaping/harfbuzz.rs
Expand Up @@ -576,13 +576,13 @@ extern fn glyph_h_advance_func(_: *mut hb_font_t,
fn glyph_space_advance(font: *mut Font) -> f64 {
let space_unicode = ' ';
let space_glyph: hb_codepoint_t;
match unsafe {(*font).glyph_index(space_unicode)} {
match unsafe { (*font).glyph_index(space_unicode) } {
Some(g) => {
space_glyph = g as hb_codepoint_t;
}
None => panic!("No space info")
}
let space_advance = unsafe {(*font).glyph_h_advance(space_glyph as GlyphId)};
let space_advance = unsafe { (*font).glyph_h_advance(space_glyph as GlyphId) };
space_advance
}

Expand Down
4 changes: 2 additions & 2 deletions components/plugins/utils.rs
Expand Up @@ -17,14 +17,14 @@ use syntax::ptr::P;
/// Try not to use this for types defined in crates you own, use match_lang_ty instead (for lint passes)
pub fn match_ty_unwrap<'a>(ty: &'a Ty, segments: &[&str]) -> Option<&'a [P<Ty>]> {
match ty.node {
TyPath(_, Path {segments: ref seg, ..}) => {
TyPath(_, Path { segments: ref seg, .. }) => {
// So ast::Path isn't the full path, just the tokens that were provided.
// I could muck around with the maps and find the full path
// however the more efficient way is to simply reverse the iterators and zip them
// which will compare them in reverse until one of them runs out of segments
if seg.iter().rev().zip(segments.iter().rev()).all(|(a, b)| a.identifier.name.as_str() == *b) {
match seg.last() {
Some(&PathSegment {parameters: AngleBracketedParameters(ref a), ..}) => {
Some(&PathSegment { parameters: AngleBracketedParameters(ref a), .. }) => {
Some(&a.types)
}
_ => None
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/element.rs
Expand Up @@ -1867,10 +1867,10 @@ impl Element {
}
}
// Step 6
None => {event.fire(target);}
None => { event.fire(target); }
},
// Step 6
None => {event.fire(target);}
None => { event.fire(target); }
}
// Step 7
self.set_click_in_progress(false);
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/htmlcollection.rs
Expand Up @@ -64,7 +64,7 @@ impl HTMLCollection {
}
}
}
let filter = AllElementFilter {namespace_filter: namespace_filter};
let filter = AllElementFilter { namespace_filter: namespace_filter };
HTMLCollection::create(window, root, box filter)
}

Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/progressevent.rs
Expand Up @@ -52,9 +52,9 @@ impl ProgressEvent {
type_: DOMString,
init: &ProgressEventBinding::ProgressEventInit)
-> Fallible<Root<ProgressEvent>> {
let bubbles = if init.parent.bubbles {EventBubbles::Bubbles} else {EventBubbles::DoesNotBubble};
let cancelable = if init.parent.cancelable {EventCancelable::Cancelable}
else {EventCancelable::NotCancelable};
let bubbles = if init.parent.bubbles { EventBubbles::Bubbles } else { EventBubbles::DoesNotBubble };
let cancelable = if init.parent.cancelable { EventCancelable::Cancelable }
else { EventCancelable::NotCancelable };
let ev = ProgressEvent::new(global, type_, bubbles, cancelable,
init.lengthComputable, init.loaded, init.total);
Ok(ev)
Expand Down
14 changes: 7 additions & 7 deletions components/script/dom/testbindingproxy.rs
Expand Up @@ -15,20 +15,20 @@ pub struct TestBindingProxy {
}

impl TestBindingProxyMethods for TestBindingProxy {
fn Length(&self) -> u32 {0}
fn SupportedPropertyNames(&self) -> Vec<DOMString> {vec![]}
fn GetNamedItem(&self, _: DOMString) -> DOMString {"".to_owned()}
fn Length(&self) -> u32 { 0 }
fn SupportedPropertyNames(&self) -> Vec<DOMString> { vec![] }
fn GetNamedItem(&self, _: DOMString) -> DOMString { "".to_owned() }
fn SetNamedItem(&self, _: DOMString, _: DOMString) -> () {}
fn GetItem(&self, _: u32) -> DOMString {"".to_owned()}
fn GetItem(&self, _: u32) -> DOMString { "".to_owned() }
fn SetItem(&self, _: u32, _: DOMString) -> () {}
fn RemoveItem(&self, _: DOMString) -> () {}
fn Stringifier(&self) -> DOMString {"".to_owned()}
fn Stringifier(&self) -> DOMString { "".to_owned() }
fn NamedCreator(&self, _: DOMString, _: DOMString) -> () {}
fn IndexedGetter(&self, _: u32, _: &mut bool) -> DOMString {"".to_owned()}
fn IndexedGetter(&self, _: u32, _: &mut bool) -> DOMString { "".to_owned() }
fn NamedDeleter(&self, _: DOMString) -> () {}
fn IndexedSetter(&self, _: u32, _: DOMString) -> () {}
fn NamedSetter(&self, _: DOMString, _: DOMString) -> () {}
fn IndexedCreator(&self, _: u32, _: DOMString) -> () {}
fn NamedGetter(&self, _: DOMString, _: &mut bool) -> DOMString {"".to_owned()}
fn NamedGetter(&self, _: DOMString, _: &mut bool) -> DOMString { "".to_owned() }

}
2 changes: 1 addition & 1 deletion components/script/dom/xmlhttprequest.rs
Expand Up @@ -959,7 +959,7 @@ impl XMLHttpRequest {

fn dispatch_response_progress_event(&self, type_: DOMString) {
let len = self.response.borrow().len() as u64;
let total = self.response_headers.borrow().get::<ContentLength>().map(|x| {**x as u64});
let total = self.response_headers.borrow().get::<ContentLength>().map(|x| { **x as u64 });
self.dispatch_progress_event(false, type_, len, total);
}
fn set_timeout(&self, duration_ms: u32) {
Expand Down
4 changes: 2 additions & 2 deletions components/script/timers.rs
Expand Up @@ -183,7 +183,7 @@ impl TimerManager {
if is_interval == IsInterval::NonInterval {
break;
}
} else if id == control_handle.id() {;
} else if id == control_handle.id() {
match control_port.recv().unwrap() {
TimerControlMsg::Suspend => {
let msg = control_port.recv().unwrap();
Expand All @@ -194,7 +194,7 @@ impl TimerManager {
break;
},
}
},
},
TimerControlMsg::Resume => panic!("Nothing to resume!"),
TimerControlMsg::Cancel => {
break;
Expand Down
10 changes: 10 additions & 0 deletions python/tidy.py
Expand Up @@ -243,6 +243,16 @@ def is_associated_type(match, line, index):
if match:
yield (idx + 1, "missing space before {")

# ignored cases like {} and }}
match = re.search(r"[^\s{}]}", line)
if match and not (line.startswith("use") or line.startswith("pub use")):
yield (idx + 1, "missing space before }")

# ignored cases like {} and {{
match = re.search(r"{[^\s{}]", line)
if match and not (line.startswith("use") or line.startswith("pub use")):
yield (idx + 1, "missing space after {")

# imports must be in the same line and alphabetically sorted
if line.startswith("use "):
use = line[4:]
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/net/http_loader.rs
Expand Up @@ -199,7 +199,7 @@ impl AssertMustHaveBodyRequest {
impl HttpRequest for AssertMustHaveBodyRequest {
type R = MockResponse;

fn headers_mut(&mut self) -> &mut Headers { &mut self.headers}
fn headers_mut(&mut self) -> &mut Headers { &mut self.headers }

fn send(self, body: &Option<Vec<u8>>) -> Result<MockResponse, LoadError> {
assert_eq!(self.expected_body, *body);
Expand Down

0 comments on commit 64ac4f1

Please sign in to comment.