Skip to content

Commit d015a3c

Browse files
thedukeLegNeato
authored andcommitted
(ci) Check formatting with cargo fmt (#302)
This adds a new extra CI job for checking the formatting with cargo fmt --check.
1 parent aa80ec5 commit d015a3c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1914
-1695
lines changed

azure-pipelines.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
jobs:
2-
- template: _build/azure-pipelines-template.yml
3-
parameters:
4-
name: macOS
5-
vmImage: macOS-10.13
2+
3+
- job: check_formatting
4+
pool:
5+
vmImage: ubuntu-16.04
6+
steps:
7+
- script: |
8+
curl https://sh.rustup.rs -sSf | sh -s -- -y
9+
$HOME/.cargo/bin/rustup component add rustfmt
10+
displayName: Install rust
11+
- script: |
12+
$HOME/.cargo/bin/cargo fmt -- --check
13+
displayName: Check formatting
614
715
- template: _build/azure-pipelines-template.yml
816
parameters:
917
name: Linux
1018
vmImage: ubuntu-16.04
1119

20+
- template: _build/azure-pipelines-template.yml
21+
parameters:
22+
name: macOS
23+
vmImage: macOS-10.13
24+
1225
- template: _build/azure-pipelines-template.yml
1326
parameters:
1427
name: Windows

integration_tests/juniper_2018_edition_tests/src/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,4 @@ juniper::graphql_object!(Query: () |&self| {
3131
}
3232
});
3333

34-
35-
fn main() {
36-
}
34+
fn main() {}

integration_tests/juniper_tests/src/codegen/derive_enum.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ use juniper::{self, DefaultScalarValue, FromInputValue, GraphQLType, InputValue,
88
#[graphql(name = "Some", description = "enum descr")]
99
enum SomeEnum {
1010
Regular,
11-
#[graphql(
12-
name = "FULL",
13-
description = "field descr",
14-
deprecated = "depr"
15-
)]
11+
#[graphql(name = "FULL", description = "field descr", deprecated = "depr")]
1612
Full,
1713
}
1814

integration_tests/juniper_tests/src/codegen/derive_input_object.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ fn test_derived_input_object() {
105105

106106
let input_no_defaults: InputValue = ::serde_json::from_value(json!({
107107
"regularField": "a",
108-
})).unwrap();
108+
}))
109+
.unwrap();
109110

110111
let output_no_defaults: Input = FromInputValue::from_input_value(&input_no_defaults).unwrap();
111112
assert_eq!(
@@ -123,7 +124,8 @@ fn test_derived_input_object() {
123124
"regularField": "a",
124125
"haha": 55,
125126
"other": true,
126-
})).unwrap();
127+
}))
128+
.unwrap();
127129

128130
let output: Input = FromInputValue::from_input_value(&input).unwrap();
129131
assert_eq!(

integration_tests/juniper_tests/src/codegen/derive_object.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,12 @@ fn test_derived_object() {
189189
vec![
190190
("regularField", Value::scalar(true)),
191191
("renamedField", Value::scalar(22)),
192-
].into_iter()
192+
]
193+
.into_iter()
193194
.collect(),
194195
),
195-
)].into_iter()
196+
)]
197+
.into_iter()
196198
.collect()
197199
),
198200
vec![]
@@ -252,13 +254,16 @@ fn test_derived_object_nested() {
252254
vec![
253255
("regularField", Value::scalar(false)),
254256
("renamedField", Value::scalar(333)),
255-
].into_iter()
257+
]
258+
.into_iter()
256259
.collect(),
257260
),
258-
)].into_iter()
261+
)]
262+
.into_iter()
259263
.collect(),
260264
),
261-
)].into_iter()
265+
)]
266+
.into_iter()
262267
.collect()
263268
),
264269
vec![]
@@ -297,15 +302,14 @@ fn check_descriptions(
297302
type_info.get_field_value("description"),
298303
Some(object_description)
299304
);
300-
assert!(
301-
values.contains(&Value::object(
302-
vec![
303-
("name", Value::scalar(field_name)),
304-
("description", field_value.clone()),
305-
].into_iter()
306-
.collect(),
307-
))
308-
);
305+
assert!(values.contains(&Value::object(
306+
vec![
307+
("name", Value::scalar(field_name)),
308+
("description", field_value.clone()),
309+
]
310+
.into_iter()
311+
.collect(),
312+
)));
309313
});
310314
}
311315

integration_tests/juniper_tests/src/custom_scalar.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ fn querying_long_variable() {
220220
vec![(
221221
"test".to_owned(),
222222
InputValue::Scalar(MyScalarValue::Long((::std::i32::MAX as i64) + 42)),
223-
)].into_iter()
223+
)]
224+
.into_iter()
224225
.collect(),
225226
|result| {
226227
assert_eq!(

juniper/src/ast.rs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use indexmap::IndexMap;
88

99
use executor::Variables;
1010
use parser::Spanning;
11-
use value::{ScalarRefValue, ScalarValue, DefaultScalarValue};
11+
use value::{DefaultScalarValue, ScalarRefValue, ScalarValue};
1212

1313
/// A type literal in the syntax tree
1414
///
@@ -285,7 +285,8 @@ where
285285
Spanning::unlocated(k.as_ref().to_owned()),
286286
Spanning::unlocated(v),
287287
)
288-
}).collect(),
288+
})
289+
.collect(),
289290
)
290291
}
291292

@@ -346,10 +347,7 @@ where
346347
}
347348

348349
/// View the underlying int value, if present.
349-
#[deprecated(
350-
since = "0.11.0",
351-
note = "Use `InputValue::as_scalar_value` instead"
352-
)]
350+
#[deprecated(since = "0.11.0", note = "Use `InputValue::as_scalar_value` instead")]
353351
pub fn as_int_value<'a>(&'a self) -> Option<i32>
354352
where
355353
&'a S: Into<Option<&'a i32>>,
@@ -358,10 +356,7 @@ where
358356
}
359357

360358
/// View the underlying float value, if present.
361-
#[deprecated(
362-
since = "0.11.0",
363-
note = "Use `InputValue::as_scalar_value` instead"
364-
)]
359+
#[deprecated(since = "0.11.0", note = "Use `InputValue::as_scalar_value` instead")]
365360
pub fn as_float_value<'a>(&'a self) -> Option<f64>
366361
where
367362
&'a S: Into<Option<&'a f64>>,
@@ -370,10 +365,7 @@ where
370365
}
371366

372367
/// View the underlying string value, if present.
373-
#[deprecated(
374-
since = "0.11.0",
375-
note = "Use `InputValue::as_scalar_value` instead"
376-
)]
368+
#[deprecated(since = "0.11.0", note = "Use `InputValue::as_scalar_value` instead")]
377369
pub fn as_string_value<'a>(&'a self) -> Option<&'a str>
378370
where
379371
&'a S: Into<Option<&'a String>>,
@@ -453,11 +445,12 @@ where
453445
.zip(l2.iter())
454446
.all(|(v1, v2)| v1.item.unlocated_eq(&v2.item)),
455447
(&Object(ref o1), &Object(ref o2)) => {
456-
o1.len() == o2.len() && o1.iter().all(|&(ref sk1, ref sv1)| {
457-
o2.iter().any(|&(ref sk2, ref sv2)| {
458-
sk1.item == sk2.item && sv1.item.unlocated_eq(&sv2.item)
448+
o1.len() == o2.len()
449+
&& o1.iter().all(|&(ref sk1, ref sv1)| {
450+
o2.iter().any(|&(ref sk2, ref sv2)| {
451+
sk1.item == sk2.item && sv1.item.unlocated_eq(&sv2.item)
452+
})
459453
})
460-
})
461454
}
462455
_ => false,
463456
}

juniper/src/executor/look_ahead.rs

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ where
5252
&n.item as &str,
5353
LookAheadValue::from_input_value(&i.item, vars),
5454
)
55-
}).collect(),
55+
})
56+
.collect(),
5657
),
5758
}
5859
}
@@ -134,7 +135,8 @@ where
134135
} else {
135136
false
136137
}
137-
}).unwrap_or(false),
138+
})
139+
.unwrap_or(false),
138140
("skip", &Some(ref a)) => a
139141
.item
140142
.items
@@ -150,13 +152,15 @@ where
150152
} else {
151153
false
152154
}
153-
}).unwrap_or(false),
155+
})
156+
.unwrap_or(false),
154157
("skip", &None) => false,
155158
("include", &None) => true,
156159
(_, _) => unreachable!(),
157160
}
158161
})
159-
}).unwrap_or(true)
162+
})
163+
.unwrap_or(true)
160164
}
161165

162166
pub(super) fn build_from_selection(
@@ -192,7 +196,8 @@ where
192196
.iter()
193197
.map(|p| LookAheadArgument::new(p, vars))
194198
.collect()
195-
}).unwrap_or_else(Vec::new);
199+
})
200+
.unwrap_or_else(Vec::new);
196201
let mut ret = LookAheadSelection {
197202
name,
198203
alias,
@@ -280,7 +285,8 @@ where
280285
}
281286
Applies::All => Some(c.inner.for_explicit_type(type_name)),
282287
Applies::OnlyType(_) => None,
283-
}).collect(),
288+
})
289+
.collect(),
284290
name: self.name,
285291
alias: self.alias,
286292
arguments: self.arguments.clone(),
@@ -390,7 +396,8 @@ query Hero {
390396
}
391397
}
392398
",
393-
).unwrap();
399+
)
400+
.unwrap();
394401
let fragments = extract_fragments(&docs);
395402

396403
if let ::ast::Definition::Operation(ref op) = docs[0] {
@@ -442,7 +449,8 @@ query Hero {
442449
}
443450
}
444451
",
445-
).unwrap();
452+
)
453+
.unwrap();
446454
let fragments = extract_fragments(&docs);
447455

448456
if let ::ast::Definition::Operation(ref op) = docs[0] {
@@ -498,7 +506,8 @@ query Hero {
498506
}
499507
}
500508
",
501-
).unwrap();
509+
)
510+
.unwrap();
502511
let fragments = extract_fragments(&docs);
503512

504513
if let ::ast::Definition::Operation(ref op) = docs[0] {
@@ -578,7 +587,8 @@ query Hero {
578587
}
579588
}
580589
",
581-
).unwrap();
590+
)
591+
.unwrap();
582592
let fragments = extract_fragments(&docs);
583593

584594
if let ::ast::Definition::Operation(ref op) = docs[0] {
@@ -636,7 +646,8 @@ query Hero($episode: Episode) {
636646
}
637647
}
638648
",
639-
).unwrap();
649+
)
650+
.unwrap();
640651
let fragments = extract_fragments(&docs);
641652

642653
if let ::ast::Definition::Operation(ref op) = docs[0] {
@@ -697,7 +708,8 @@ fragment commonFields on Character {
697708
appearsIn
698709
}
699710
",
700-
).unwrap();
711+
)
712+
.unwrap();
701713
let fragments = extract_fragments(&docs);
702714

703715
if let ::ast::Definition::Operation(ref op) = docs[0] {
@@ -759,7 +771,8 @@ query Hero {
759771
height @skip(if: false)
760772
}
761773
}",
762-
).unwrap();
774+
)
775+
.unwrap();
763776
let fragments = extract_fragments(&docs);
764777

765778
if let ::ast::Definition::Operation(ref op) = docs[0] {
@@ -815,7 +828,8 @@ query Hero {
815828
}
816829
}
817830
}",
818-
).unwrap();
831+
)
832+
.unwrap();
819833
let fragments = extract_fragments(&docs);
820834

821835
if let ::ast::Definition::Operation(ref op) = docs[0] {
@@ -887,7 +901,8 @@ fragment comparisonFields on Character {
887901
... on Droid { primaryFunction }
888902
... on Human { height }
889903
}",
890-
).unwrap();
904+
)
905+
.unwrap();
891906
let fragments = extract_fragments(&docs);
892907

893908
if let ::ast::Definition::Operation(ref op) = docs[0] {
@@ -1043,7 +1058,8 @@ query Hero {
10431058
}
10441059
}
10451060
}",
1046-
).unwrap();
1061+
)
1062+
.unwrap();
10471063
let fragments = extract_fragments(&docs);
10481064

10491065
if let ::ast::Definition::Operation(ref op) = docs[0] {
@@ -1052,7 +1068,8 @@ query Hero {
10521068
&op.item.selection_set[0],
10531069
&vars,
10541070
&fragments,
1055-
).for_explicit_type("Human");
1071+
)
1072+
.for_explicit_type("Human");
10561073
let expected = ConcreteLookAheadSelection {
10571074
name: "hero",
10581075
alias: None,

0 commit comments

Comments
 (0)