Skip to content

Commit 7848cfe

Browse files
committed
Fix clippy lints
1 parent b126670 commit 7848cfe

4 files changed

Lines changed: 8 additions & 25 deletions

File tree

src/commands.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,7 @@ pub fn handle(matches: &clap::ArgMatches, io: &mut dyn Io) {
6161

6262
match matches.subcommand() {
6363
Some(("login", args)) => {
64-
let interactive_mode;
65-
if args.is_present("non-interactive") {
66-
interactive_mode = false;
67-
} else {
68-
interactive_mode = true;
69-
}
64+
let interactive_mode = !args.is_present("non-interactive");
7065
login(io, &mut client, interactive_mode)
7166
}
7267
Some(("download", args)) => download_or_update(
@@ -79,12 +74,7 @@ pub fn handle(matches: &clap::ArgMatches, io: &mut dyn Io) {
7974
update(io, &mut client, args.is_present("currentdir"));
8075
}
8176
Some(("organization", args)) => {
82-
let interactive_mode;
83-
if args.is_present("non-interactive") {
84-
interactive_mode = false;
85-
} else {
86-
interactive_mode = true;
87-
}
77+
let interactive_mode = !args.is_present("non-interactive");
8878
organization(io, &mut client, interactive_mode)
8979
}
9080
Some(("courses", _)) => list_courses(io, &mut client),

src/commands/command_util.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,6 @@ impl Client for ClientProduction {
172172
}
173173

174174
fn try_login(&mut self, username: String, password: String) -> Result<String, String> {
175-
let token;
176-
177175
if self.test_mode {
178176
if username == "testusername" && password == "testpassword" {
179177
let mut config = TmcConfig::load(PLUGIN, &get_path()).unwrap();
@@ -193,11 +191,8 @@ impl Client for ClientProduction {
193191
}
194192
return Err(WRONG_LOGIN.to_string());
195193
}
196-
match self.authenticate(username, password) {
197-
Ok(x) => token = x,
198-
Err(x) => return Err(x),
199-
}
200194

195+
let token = self.authenticate(username, password)?;
201196
if Credentials::save(PLUGIN, token).is_ok() {
202197
return Ok(SUCCESSFUL_LOGIN.to_string());
203198
};

src/commands/login_command.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ pub fn login(io: &mut dyn Io, client: &mut dyn Client, interactive_mode: bool) {
1414

1515
io.print("Password: ", PrintColor::Normal);
1616

17-
let mut password;
18-
1917
// Read password without rpassword if ran in --testmode, because rpassword
2018
// is not able to read mock stdin input in binary tests
21-
if client.is_test_mode() {
22-
password = io.read_line();
19+
let mut password = if client.is_test_mode() {
20+
io.read_line()
2321
} else {
24-
password = io.read_password();
25-
}
22+
io.read_password()
23+
};
2624
password = password.trim().to_string();
2725

2826
match client.try_login(username, password) {

src/commands/submit_command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn print_wait_for_submission_results(io: &mut dyn Io, submission_finished: Submi
132132
} else {
133133
io.println(&format!("Failed: {}", case.name), PrintColor::Failed);
134134
if let Some(message) = case.message {
135-
let formatted = message.replace("\n", "\n ");
135+
let formatted = message.replace('\n', "\n ");
136136
io.println(&format!(" {}", formatted), PrintColor::Normal);
137137
}
138138
io.println("", PrintColor::Normal);

0 commit comments

Comments
 (0)