Skip to content

Commit 3a8d3a0

Browse files
tesujiCentril
authored andcommitted
Run cargo fmt on whole project (#272)
* Fix fallback in #270 Wrong order of arguments in `format!`. * fmt: Remove invalid struct_lit_width option * ci: Reformat travis config * ci: Checking style before build * fmt: Run cargo fmt on whole project
1 parent 76c141b commit 3a8d3a0

19 files changed

+950
-617
lines changed

.travis.yml

+27-24
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ notifications:
33
email: false
44
language: rust
55
rust:
6-
- nightly
6+
- nightly
77
cache:
88
cargo: true
99
directories:
@@ -15,31 +15,34 @@ addons:
1515
- curl
1616
- libpq-dev
1717
- pkg-config
18+
before_install:
19+
- rustup component add rustfmt
20+
- cargo fmt --all -- --check
1821
install:
19-
- export RUST_LOG=debug,hyper=info,rustc=error,cargo=error,jobserver=error
20-
- export GITHUB_WEBHOOK_SECRETS=none
21-
- export GITHUB_ACCESS_TOKEN=
22-
- export GITHUB_SCRAPE_INTERVAL=6000
23-
- export GITHUB_USER_AGENT=none-agent-with-left-beef
24-
- export POST_COMMENTS=false
25-
- export RUST_BACKTRACE=1
26-
- export PATH=$PATH:$HOME/.cargo/bin
27-
- export DATABASE_URL=postgres://localhost/dashboard
28-
- export DATABASE_POOL_SIZE=5
29-
- rustup default $(cat rust-toolchain)
30-
- cargo install cargo-update || true
31-
- cargo install-update-config diesel_cli --default-features false --feature postgres
32-
- cargo install-update -i diesel_cli
22+
- export RUST_LOG=debug,hyper=info,rustc=error,cargo=error,jobserver=error
23+
- export GITHUB_WEBHOOK_SECRETS=none
24+
- export GITHUB_ACCESS_TOKEN=
25+
- export GITHUB_SCRAPE_INTERVAL=6000
26+
- export GITHUB_USER_AGENT=none-agent-with-left-beef
27+
- export POST_COMMENTS=false
28+
- export RUST_BACKTRACE=1
29+
- export PATH=$PATH:$HOME/.cargo/bin
30+
- export DATABASE_URL=postgres://localhost/dashboard
31+
- export DATABASE_POOL_SIZE=5
32+
- rustup default $(cat rust-toolchain)
33+
- cargo install cargo-update || true
34+
- cargo install-update-config diesel_cli --default-features false --feature postgres
35+
- cargo install-update -i diesel_cli
3336
before_script:
34-
- diesel setup
35-
- diesel migration run
36-
- psql -q -d $DATABASE_URL < githubuser-backup.pg
37+
- diesel setup
38+
- diesel migration run
39+
- psql -q -d $DATABASE_URL < githubuser-backup.pg
3740
script:
38-
- cargo build
39-
- cargo test
41+
- cargo build
42+
- cargo test
4043
before_deploy:
41-
- DATABASE_URL=$(heroku config:get DATABASE_URL -a rfcbot-rs) diesel migration run
44+
- DATABASE_URL=$(heroku config:get DATABASE_URL -a rfcbot-rs) diesel migration run
4245
deploy:
43-
provider: heroku
44-
api_key:
45-
secure: "HgoF2n6pnzUhZ4oBNRo3gSoxj/o9x7QW0fKaj9sEYDNkTgak9IX3ha0antoYKB7dMw7IvB8oqVAHqldlGlG/kxUDKN8kaYA4O7CZgKP0auykTkmH61FP7MKV0hV0vyFfJLSraClVw/DL5tjYybs/rSBWFAvwttIB7QlcFv5sLIuwe5nHzftFfxba0H1+0oynO55FlmRzFBWydlFVNTsGVRddFHPgG3f2V9YYIjT18MKvn+BcV7WUq6QweB/3RjwTDYzws9mcWt6i3ju1D4nDTDVbtzeLs7Yt+NhnvrDeB+2FWSrV03LCjnnzv2zCUaROU522Vns0ZC/+2b9V3YbcCBJRA8QLBdo12JUCUzrdk8DOqIYKwlW6WbI3DcgRGz9Li7Dw2466+lsPidBfcdxnziTvc+r/2r6dKv3q7nwDpoZEyxnnTumPf50PJZs/lDu99Vo5C2NIdN2O5sqDHd8AJTLtWrY3FdN5MGKqTm0R9rVnObvUkTKbZJrDn39O5MU3mnHINUT+6ZCnNgra7rNn7Ai3tA1RKPB7kIZo41Td8j56iSLANXziCh0MikPfQv4x1scl3c1h5bR8ZqxVqH4IODjDJrJv43+hsbE9xGsmrC4OaqImLUpl/8zi6a4zZ8Na1AiFKVcdLZ9xt40/2yg7ysn53SCpQ5vty/j36clNwAE="
46+
- provider: heroku
47+
api_key:
48+
secure: "HgoF2n6pnzUhZ4oBNRo3gSoxj/o9x7QW0fKaj9sEYDNkTgak9IX3ha0antoYKB7dMw7IvB8oqVAHqldlGlG/kxUDKN8kaYA4O7CZgKP0auykTkmH61FP7MKV0hV0vyFfJLSraClVw/DL5tjYybs/rSBWFAvwttIB7QlcFv5sLIuwe5nHzftFfxba0H1+0oynO55FlmRzFBWydlFVNTsGVRddFHPgG3f2V9YYIjT18MKvn+BcV7WUq6QweB/3RjwTDYzws9mcWt6i3ju1D4nDTDVbtzeLs7Yt+NhnvrDeB+2FWSrV03LCjnnzv2zCUaROU522Vns0ZC/+2b9V3YbcCBJRA8QLBdo12JUCUzrdk8DOqIYKwlW6WbI3DcgRGz9Li7Dw2466+lsPidBfcdxnziTvc+r/2r6dKv3q7nwDpoZEyxnnTumPf50PJZs/lDu99Vo5C2NIdN2O5sqDHd8AJTLtWrY3FdN5MGKqTm0R9rVnObvUkTKbZJrDn39O5MU3mnHINUT+6ZCnNgra7rNn7Ai3tA1RKPB7kIZo41Td8j56iSLANXziCh0MikPfQv4x1scl3c1h5bR8ZqxVqH4IODjDJrJv43+hsbE9xGsmrC4OaqImLUpl/8zi6a4zZ8Na1AiFKVcdLZ9xt40/2yg7ysn53SCpQ5vty/j36clNwAE="

rustfmt.toml

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
struct_lit_width = 24
21
fn_single_line = true
32
format_strings = false

src/config.rs

+28-25
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ lazy_static! {
1212
Ok(c) => {
1313
info!("Configuration parsed from environment variables.");
1414
c
15-
},
15+
}
1616
Err(missing) => {
1717
error!("Unable to load environment variables {:?}", missing);
1818
panic!("Unable to load environment variables {:?}", missing);
19-
},
19+
}
2020
}
2121
};
2222
}
@@ -34,8 +34,9 @@ pub struct Config {
3434

3535
impl Config {
3636
pub fn check(&self) -> bool {
37-
!self.db_url.is_empty() && !self.github_access_token.is_empty() &&
38-
!self.github_user_agent.is_empty()
37+
!self.db_url.is_empty()
38+
&& !self.github_access_token.is_empty()
39+
&& !self.github_user_agent.is_empty()
3940
}
4041
}
4142

@@ -50,22 +51,24 @@ const POST_COMMENTS: &'static str = "POST_COMMENTS";
5051
// this is complex, but we'll shortly need a lot more config items
5152
// so checking them automagically seems like a nice solution
5253
pub fn init() -> Result<Config, Vec<&'static str>> {
53-
5454
let mut vars: BTreeMap<&'static str, Result<String, _>> = BTreeMap::new();
55-
let keys = vec![DB_URL,
56-
DB_POOL_SIZE,
57-
GITHUB_TOKEN,
58-
GITHUB_WEBHOOK_SECRETS,
59-
GITHUB_UA,
60-
POST_COMMENTS];
55+
let keys = vec![
56+
DB_URL,
57+
DB_POOL_SIZE,
58+
GITHUB_TOKEN,
59+
GITHUB_WEBHOOK_SECRETS,
60+
GITHUB_UA,
61+
POST_COMMENTS,
62+
];
6163

6264
for var in keys {
6365
vars.insert(var, env::var(var));
6466
}
6567

6668
let all_found = vars.iter().all(|(_, v)| v.is_ok());
6769
if all_found {
68-
let mut vars = vars.into_iter()
70+
let mut vars = vars
71+
.into_iter()
6972
.map(|(k, v)| (k, v.unwrap()))
7073
.collect::<BTreeMap<_, _>>();
7174

@@ -89,19 +92,19 @@ pub fn init() -> Result<Config, Vec<&'static str>> {
8992
let webhook_secrets = webhook_secrets.split(',').map(String::from).collect();
9093

9194
Ok(Config {
92-
db_url: db_url,
93-
db_pool_size: db_pool_size,
94-
github_access_token: gh_token,
95-
github_user_agent: gh_ua,
96-
github_webhook_secrets: webhook_secrets,
97-
github_interval_mins: gh_interval,
98-
post_comments: post_comments,
99-
})
100-
95+
db_url: db_url,
96+
db_pool_size: db_pool_size,
97+
github_access_token: gh_token,
98+
github_user_agent: gh_ua,
99+
github_webhook_secrets: webhook_secrets,
100+
github_interval_mins: gh_interval,
101+
post_comments: post_comments,
102+
})
101103
} else {
102-
Err(vars.iter()
103-
.filter(|&(_, v)| v.is_err())
104-
.map(|(&k, _)| k)
105-
.collect())
104+
Err(vars
105+
.iter()
106+
.filter(|&(_, v)| v.is_err())
107+
.map(|(&k, _)| k)
108+
.collect())
106109
}
107110
}

src/domain/github.rs

+56-20
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use chrono::NaiveDateTime;
55
use super::schema::*;
66

77
#[derive(AsChangeset, Clone, Debug, Queryable)]
8-
#[table_name="githubsync"]
8+
#[table_name = "githubsync"]
99
pub struct GitHubSync {
1010
pub id: i32,
1111
pub successful: bool,
@@ -14,24 +14,36 @@ pub struct GitHubSync {
1414
}
1515

1616
#[derive(Clone, Debug, Insertable)]
17-
#[table_name="githubsync"]
17+
#[table_name = "githubsync"]
1818
pub struct GitHubSyncPartial {
1919
pub successful: bool,
2020
pub ran_at: NaiveDateTime,
2121
pub message: Option<String>,
2222
}
2323

24-
#[derive(AsChangeset, Clone, Debug, Deserialize, Eq, Insertable,
25-
Ord, PartialEq, PartialOrd, Queryable, Serialize)]
26-
#[table_name="githubuser"]
24+
#[derive(
25+
AsChangeset,
26+
Clone,
27+
Debug,
28+
Deserialize,
29+
Eq,
30+
Insertable,
31+
Ord,
32+
PartialEq,
33+
PartialOrd,
34+
Queryable,
35+
Serialize,
36+
)]
37+
#[table_name = "githubuser"]
2738
pub struct GitHubUser {
2839
pub id: i32,
2940
pub login: String,
3041
}
3142

32-
#[derive(AsChangeset, Clone, Debug, Deserialize, Eq, Insertable,
33-
Ord, PartialEq, PartialOrd, Queryable)]
34-
#[table_name="milestone"]
43+
#[derive(
44+
AsChangeset, Clone, Debug, Deserialize, Eq, Insertable, Ord, PartialEq, PartialOrd, Queryable,
45+
)]
46+
#[table_name = "milestone"]
3547
#[changeset_options(treat_none_as_null = "true")]
3648
pub struct Milestone {
3749
pub id: i32,
@@ -49,9 +61,20 @@ pub struct Milestone {
4961
pub repository: String,
5062
}
5163

52-
#[derive(AsChangeset, Clone, Debug, Deserialize, Eq, Insertable,
53-
Ord, PartialEq, PartialOrd, Queryable, Serialize)]
54-
#[table_name="issue"]
64+
#[derive(
65+
AsChangeset,
66+
Clone,
67+
Debug,
68+
Deserialize,
69+
Eq,
70+
Insertable,
71+
Ord,
72+
PartialEq,
73+
PartialOrd,
74+
Queryable,
75+
Serialize,
76+
)]
77+
#[table_name = "issue"]
5578
pub struct IssuePartial {
5679
pub number: i32,
5780
pub fk_milestone: Option<i32>,
@@ -91,9 +114,10 @@ impl IssuePartial {
91114
}
92115
}
93116

94-
#[derive(AsChangeset, Clone, Debug, Deserialize, Eq, Ord,
95-
PartialEq, PartialOrd, Queryable, Serialize)]
96-
#[table_name="issue"]
117+
#[derive(
118+
AsChangeset, Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Queryable, Serialize,
119+
)]
120+
#[table_name = "issue"]
97121
#[changeset_options(treat_none_as_null = "true")]
98122
pub struct Issue {
99123
pub id: i32,
@@ -113,9 +137,20 @@ pub struct Issue {
113137
pub repository: String,
114138
}
115139

116-
#[derive(AsChangeset, Clone, Debug, Deserialize, Eq, Insertable,
117-
Ord, PartialEq, PartialOrd, Queryable, Serialize)]
118-
#[table_name="issuecomment"]
140+
#[derive(
141+
AsChangeset,
142+
Clone,
143+
Debug,
144+
Deserialize,
145+
Eq,
146+
Insertable,
147+
Ord,
148+
PartialEq,
149+
PartialOrd,
150+
Queryable,
151+
Serialize,
152+
)]
153+
#[table_name = "issuecomment"]
119154
#[changeset_options(treat_none_as_null = "true")]
120155
pub struct IssueComment {
121156
pub id: i32,
@@ -127,9 +162,10 @@ pub struct IssueComment {
127162
pub repository: String,
128163
}
129164

130-
#[derive(AsChangeset, Clone, Debug, Deserialize, Eq, Insertable,
131-
Ord, PartialEq, PartialOrd, Queryable)]
132-
#[table_name="pullrequest"]
165+
#[derive(
166+
AsChangeset, Clone, Debug, Deserialize, Eq, Insertable, Ord, PartialEq, PartialOrd, Queryable,
167+
)]
168+
#[table_name = "pullrequest"]
133169
#[changeset_options(treat_none_as_null = "true")]
134170
pub struct PullRequest {
135171
pub number: i32,

0 commit comments

Comments
 (0)