Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a6aa1b5

Browse files
feat(ci): add clippy check to ci
1 parent f4db1ca commit a6aa1b5

File tree

7 files changed

+65
-31
lines changed

7 files changed

+65
-31
lines changed

‎.github/workflows/clippy.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Clippy Check
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
clippy:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [macOS-latest, ubuntu-latest]
15+
steps:
16+
- uses: actions/checkout@v1
17+
- uses: actions-rs/toolchain@v1
18+
with:
19+
toolchain: stable
20+
components: clippy
21+
override: true
22+
- uses: actions-rs/clippy-check@v1
23+
with:
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
args: --all-features

‎src/cache/models.rs

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ impl std::fmt::Display for Problem {
5757
1 => {
5858
id.push_str(&SPACE.repeat(2));
5959
id.push_str(&self.fid.to_string());
60-
id.push_str(&SPACE.repeat(1));
60+
id.push_str(&SPACE.to_string());
6161
}
6262
2 => {
63-
id.push_str(&SPACE.repeat(1));
63+
id.push_str(&SPACE.to_string());
6464
id.push_str(&self.fid.to_string());
65-
id.push_str(&SPACE.repeat(1));
65+
id.push_str(&SPACE.to_string());
6666
}
6767
3 => {
68-
id.push_str(&SPACE.repeat(1));
68+
id.push_str(&SPACE.to_string());
6969
id.push_str(&self.fid.to_string());
7070
}
7171
4 => {
@@ -304,26 +304,30 @@ impl std::fmt::Display for VerifyResult {
304304
}
305305
write!(
306306
f,
307-
"\n{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}.\n\n",
307+
"\n{}{}{}\
308+
, faster than \
309+
{}{}\
310+
of \
311+
{} \
312+
online submissions for \
313+
{}.\n\n\
314+
{}{}\
315+
, less than \
316+
{}{} \
317+
of \
318+
{}{}.\n\n",
308319
"Success\n\n".green().bold(),
309320
"Runtime: ".dimmed(),
310321
&self.status.status_runtime.bold(),
311-
", faster than ",
312322
rp.to_string().bold(),
313323
"% ".bold(),
314-
"of ",
315324
&self.pretty_lang,
316-
" online submissions for ",
317325
&self.name,
318-
".\n\n",
319326
"Memory Usage: ".dimmed(),
320327
&self.status.status_memory.bold(),
321-
", less than ",
322328
mp.to_string().bold(),
323329
"% ".bold(),
324-
"of ",
325330
&self.pretty_lang,
326-
" online submissions for ",
327331
&self.name,
328332
)?
329333
} else {
@@ -400,7 +404,7 @@ impl std::fmt::Display for VerifyResult {
400404

401405
match &self.result_type {
402406
Run::Test => {
403-
if &self.code_output.len() > &0 {
407+
if !self.code_output.is_empty() {
404408
write!(
405409
f,
406410
"{}{}",
@@ -412,7 +416,7 @@ impl std::fmt::Display for VerifyResult {
412416
}
413417
}
414418
_ => {
415-
if &self.std_output.len() > &0 {
419+
if !self.std_output.is_empty() {
416420
write!(
417421
f,
418422
"{}{}",
@@ -510,19 +514,19 @@ mod verify {
510514

511515
/// Formatter for str
512516
trait Formatter {
513-
fn after_spaces<'f>(&self, spaces: usize) -> String;
514-
fn before_spaces<'f>(&self, spaces: usize) -> String;
517+
fn after_spaces(&self, spaces: usize) -> String;
518+
fn before_spaces(&self, spaces: usize) -> String;
515519
}
516520

517521
impl Formatter for str {
518-
fn after_spaces<'f>(&self, spaces: usize) -> String {
522+
fn after_spaces(&self, spaces: usize) -> String {
519523
let mut r = String::new();
520524
r.push_str(self);
521525
r.push_str(&" ".repeat(spaces));
522526
r
523527
}
524528

525-
fn before_spaces<'f>(&self, spaces: usize) -> String {
529+
fn before_spaces(&self, spaces: usize) -> String {
526530
let mut r = String::new();
527531
r.push_str(&" ".repeat(spaces));
528532
r.push_str(self);

‎src/cli.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ pub fn main() -> Result<(), Error> {
3636
.init();
3737
}
3838

39-
let mut runtime = Builder::new().build().unwrap();
39+
let mut runtime = Builder::new()
40+
.basic_scheduler()
41+
.enable_all()
42+
.build()
43+
.unwrap();
4044
match m.subcommand() {
4145
("data", Some(sub_m)) => Ok(DataCommand::handler(sub_m, &mut runtime)?),
4246
("edit", Some(sub_m)) => Ok(EditCommand::handler(sub_m, &mut runtime)?),

‎src/cmds/list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ impl Command for ListCommand {
125125
trace!("Input list command...");
126126

127127
let cache = Cache::new()?;
128-
let mut ps = cache.clone().get_problems()?;
128+
let mut ps = cache.get_problems()?;
129129

130130
// if cache doesn't exist, request a new copy
131131
if ps.is_empty() {
132-
runtime.block_on(cache.clone().download_problems())?;
132+
runtime.block_on(cache.download_problems())?;
133133
return Self::handler(m, runtime);
134134
}
135135

‎src/cmds/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl Command for TestCommand {
4949
let testcase = m.value_of("testcase");
5050
let case_str: Option<String>;
5151
match testcase {
52-
Some(case) => case_str = Option::from(case.replace("\\n", "\n").to_string()),
52+
Some(case) => case_str = Option::from(case.replace("\\n", "\n")),
5353
_ => case_str = None,
5454
}
5555
let cache = Cache::new()?;

‎src/err.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,16 @@ impl std::fmt::Debug for Error {
2525
Error::CacheError(s) => write!(f, "{} {}, please try again", e, s),
2626
Error::CookieError => write!(
2727
f,
28-
"{} {}{}{}{}{}",
28+
"{} \
29+
Your leetcode cookies seems expired, \
30+
{} \
31+
Either you can handwrite your `LEETCODE_SESSION` and `csrf` into `leetcode.toml`, \
32+
more info please checkout this: \
33+
https://github.com/clearloop/leetcode-cli/blob/master/README.md#cookies",
2934
e,
30-
"Your leetcode cookies seems expired, ",
3135
"please make sure you have logined in leetcode.com with chrome. "
3236
.yellow()
3337
.bold(),
34-
"Either you can handwrite your `LEETCODE_SESSION` and `csrf` into `leetcode.toml`, ",
35-
"more info please checkout this: ",
36-
"https://github.com/clearloop/leetcode-cli/blob/master/README.md#cookies"
3738
),
3839
Error::DownloadError(s) => write!(f, "{} Download {} failed, please try again", e, s),
3940
Error::NetworkError(s) => write!(f, "{} {}, please try again", e, s),

‎src/helper.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,17 @@ mod html {
124124
8 => "8".to_string(),
125125
9 => "9".to_string(),
126126
x if x > 10 => (superscript(n / 10).parse().unwrap_or(0)
127-
+ &superscript(n % 10).parse().unwrap_or(0))
128-
.to_string(),
127+
+ superscript(n % 10).parse().unwrap_or(0))
128+
.to_string(),
129129
_ => n.to_string(),
130130
}
131131
}
132132

133133
pub fn subscript(n: u8) -> String {
134134
match n {
135135
x if x >= 10 => (subscript(n / 10).parse().unwrap_or(0)
136-
+ &subscript(n % 10).parse().unwrap_or(0))
137-
.to_string(),
136+
+ subscript(n % 10).parse().unwrap_or(0))
137+
.to_string(),
138138
0 => "0".to_string(),
139139
1 => "1".to_string(),
140140
2 => "2".to_string(),

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /