Skip to content

Commit d0e1f70

Browse files
committed
0.18.0
1 parent f1eda23 commit d0e1f70

Some content is hidden

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

46 files changed

+181
-130
lines changed

plugins/csharp/src/cs_test_result.rs

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ impl CSTestResult {
3030
}
3131

3232
#[cfg(test)]
33+
#[allow(clippy::clippy::unwrap_used)]
3334
mod test {
3435
use super::*;
3536

plugins/csharp/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(clippy::print_stdout, clippy::print_stderr)]
1+
#![deny(clippy::print_stdout, clippy::print_stderr, clippy::unwrap_used)]
22

33
//! TMC language plugin for C#.
44

plugins/csharp/src/plugin.rs

+1
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ impl LanguagePlugin for CSharpPlugin {
348348
}
349349

350350
#[cfg(test)]
351+
#[allow(clippy::clippy::unwrap_used)]
351352
mod test {
352353
use super::*;
353354
use once_cell::sync::Lazy;

plugins/java/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ tmc-langs-util = { path = "../../tmc-langs-util" }
1212
dirs = "3"
1313
flate2 = "1"
1414
j4rs = "0.13.0" # specific version to match the jar
15-
lazy_static = "1"
1615
log = "0.4"
16+
once_cell = "1"
1717
serde = { version = "1", features = ["derive"] }
1818
serde_json = "1"
1919
tar = "0.4"

plugins/java/src/ant_plugin.rs

+1
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ impl JavaPlugin for AntPlugin {
268268
}
269269

270270
#[cfg(test)]
271+
#[allow(clippy::clippy::unwrap_used)]
271272
mod test {
272273
use super::*;
273274
use std::fs;

plugins/java/src/java_plugin.rs

+1
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ pub(crate) trait JavaPlugin: LanguagePlugin {
283283
}
284284

285285
#[cfg(test)]
286+
#[allow(clippy::clippy::unwrap_used)]
286287
mod test {
287288
use crate::SEPARATOR;
288289

plugins/java/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(clippy::print_stdout, clippy::print_stderr)]
1+
#![deny(clippy::print_stdout, clippy::print_stderr, clippy::unwrap_used)]
22

33
//! Java plugins for ant and maven
44

plugins/java/src/maven_plugin.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -245,18 +245,18 @@ impl JavaPlugin for MavenPlugin {
245245

246246
#[cfg(test)]
247247
#[cfg(not(target_os = "macos"))] // issues with maven dependencies
248+
#[allow(clippy::unwrap_used)]
248249
mod test {
249250

250251
use super::super::{TestCase, TestCaseStatus};
251252
use super::*;
253+
use once_cell::sync::Lazy;
252254
use std::fs;
253255
use std::sync::{Mutex, MutexGuard};
254256
use tmc_langs_framework::StyleValidationStrategy;
255257
use zip::ZipArchive;
256258

257-
lazy_static::lazy_static! {
258-
static ref MAVEN_LOCK: Mutex<()> = Mutex::new(());
259-
}
259+
static MAVEN_LOCK: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));
260260

261261
fn init() {
262262
use log::*;

plugins/make/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ license = "MIT OR Apache-2.0"
99
tmc-langs-framework = { path = "../../tmc-langs-framework" }
1010
tmc-langs-util = { path = "../../tmc-langs-util" }
1111

12-
lazy_static = "1"
1312
log = "0.4"
13+
once_cell = "1"
1414
regex = "1"
1515
serde = { version = "1", features = ["derive"] }
1616
serde_yaml = "0.8"

plugins/make/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(clippy::print_stdout, clippy::print_stderr)]
1+
#![deny(clippy::print_stdout, clippy::print_stderr, clippy::unwrap_used)]
22

33
//! TMC plugin for make.
44

plugins/make/src/plugin.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::check_log::CheckLog;
44
use crate::error::MakeError;
55
use crate::policy::MakeStudentFilePolicy;
66
use crate::valgrind_log::ValgrindLog;
7-
use lazy_static::lazy_static;
7+
use once_cell::sync::Lazy;
88
use regex::Regex;
99
use std::collections::HashMap;
1010
use std::io::{self, BufRead, BufReader, Read, Seek};
@@ -33,12 +33,12 @@ impl MakePlugin {
3333
available_points: &Path,
3434
exercise_name: String,
3535
) -> Result<ExerciseDesc, MakeError> {
36-
lazy_static! {
37-
// "[test] [test_one] 1.1 1.2 1.3" = "[type] [name] points"
38-
// TODO: use parser lib
39-
static ref RE: Regex =
40-
Regex::new(r#"\[(?P<type>.*)\] \[(?P<name>.*)\] (?P<points>.*)"#).unwrap();
41-
}
36+
// "[test] [test_one] 1.1 1.2 1.3" = "[type] [name] points"
37+
// TODO: use parser lib
38+
#[allow(clippy::clippy::unwrap_used)]
39+
static RE: Lazy<Regex> = Lazy::new(|| {
40+
Regex::new(r#"\[(?P<type>.*)\] \[(?P<name>.*)\] (?P<points>.*)"#).unwrap()
41+
});
4242

4343
let mut tests = vec![];
4444

@@ -383,6 +383,7 @@ impl LanguagePlugin for MakePlugin {
383383

384384
#[cfg(test)]
385385
#[cfg(target_os = "linux")] // check not installed on other CI platforms
386+
#[allow(clippy::clippy::unwrap_used)]
386387
mod test {
387388
use super::*;
388389
use zip::ZipArchive;

plugins/make/src/valgrind_log.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Contains a struct representing valgrind's log output.
22
33
use crate::error::MakeError;
4-
use lazy_static::lazy_static;
4+
use once_cell::sync::Lazy;
55
use regex::Regex;
66
use std::collections::HashMap;
77
use std::io::{BufRead, BufReader};
@@ -21,11 +21,11 @@ impl ValgrindLog {
2121
// TODO: use parsing lib?
2222
log::debug!("parsing {}", valgrind_log_path.display());
2323

24-
lazy_static! {
25-
static ref PID_REGEX: Regex = Regex::new(r#"==(?P<pid>\d+)=="#).unwrap();
26-
static ref ERR_REGEX: Regex =
27-
Regex::new(r#"== ERROR SUMMARY: (?P<error_count>\d+)"#).unwrap();
28-
}
24+
#[allow(clippy::clippy::unwrap_used)]
25+
static PID_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r#"==(?P<pid>\d+)=="#).unwrap());
26+
#[allow(clippy::clippy::unwrap_used)]
27+
static ERR_REGEX: Lazy<Regex> =
28+
Lazy::new(|| Regex::new(r#"== ERROR SUMMARY: (?P<error_count>\d+)"#).unwrap());
2929

3030
let valgrind_log_file = file_util::open_file(valgrind_log_path)?;
3131
let valgrind_log = BufReader::new(valgrind_log_file);
@@ -53,7 +53,9 @@ impl ValgrindLog {
5353
Some(first_pid) => first_pid,
5454
None => return Err(MakeError::NoPidsInValgrindLogs),
5555
};
56-
let (header_log, _header_errors) = pid_info.remove(&first_pid).unwrap();
56+
let (header_log, _header_errors) = pid_info
57+
.remove(&first_pid)
58+
.expect("pid_info should have info for every pid");
5759

5860
let mut contains_errors = false;
5961
let mut results = vec![];
@@ -82,6 +84,7 @@ pub struct ValgrindResult {
8284
}
8385

8486
#[cfg(test)]
87+
#[allow(clippy::clippy::unwrap_used)]
8588
mod test {
8689
use super::*;
8790

plugins/notests/src/plugin.rs

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ impl LanguagePlugin for NoTestsPlugin {
102102
}
103103

104104
#[cfg(test)]
105+
#[allow(clippy::unwrap_used)]
105106
mod test {
106107
use super::*;
107108

plugins/python3/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ tmc-langs-util = { path = "../../tmc-langs-util" }
1212
dunce = "1"
1313
hex = "0.4"
1414
hmac = "0.10"
15-
lazy_static = "1"
1615
log = "0.4"
16+
once_cell = "1"
1717
rand = "0.8"
1818
serde = "1"
1919
serde_json = "1"

plugins/python3/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(clippy::print_stdout, clippy::print_stderr)]
1+
#![deny(clippy::print_stdout, clippy::print_stderr, clippy::unwrap_used)]
22

33
//! Implementation of LanguagePlugin for Python 3.
44

plugins/python3/src/plugin.rs

+25-23
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::error::PythonError;
44
use crate::policy::Python3StudentFilePolicy;
55
use crate::python_test_result::PythonTestResult;
66
use hmac::{Hmac, Mac, NewMac};
7-
use lazy_static::lazy_static;
7+
use once_cell::sync::Lazy;
88
use rand::Rng;
99
use sha2::Sha256;
1010
use std::collections::{HashMap, HashSet};
@@ -32,31 +32,32 @@ impl Python3Plugin {
3232
}
3333

3434
fn get_local_python_command() -> TmcCommand {
35-
lazy_static! {
36-
// the correct python command is platform-dependent
37-
static ref LOCAL_PY: LocalPy = {
38-
if let Ok(python_exec) = env::var("TMC_LANGS_PYTHON_EXEC") {
39-
log::debug!("using Python from environment variable TMC_LANGS_PYTHON_EXEC={}", python_exec);
40-
return LocalPy::Custom { python_exec };
41-
}
35+
// the correct python command is platform-dependent
36+
static LOCAL_PY: Lazy<LocalPy> = Lazy::new(|| {
37+
if let Ok(python_exec) = env::var("TMC_LANGS_PYTHON_EXEC") {
38+
log::debug!(
39+
"using Python from environment variable TMC_LANGS_PYTHON_EXEC={}",
40+
python_exec
41+
);
42+
return LocalPy::Custom { python_exec };
43+
}
4244

43-
if cfg!(windows) {
44-
// Check for Conda
45-
let conda = env::var("CONDA_PYTHON_EXE");
46-
if let Ok(conda_path) = conda {
47-
if PathBuf::from(&conda_path).exists() {
48-
log::debug!("detected conda on windows");
49-
return LocalPy::WindowsConda { conda_path };
50-
}
45+
if cfg!(windows) {
46+
// Check for Conda
47+
let conda = env::var("CONDA_PYTHON_EXE");
48+
if let Ok(conda_path) = conda {
49+
if PathBuf::from(&conda_path).exists() {
50+
log::debug!("detected conda on windows");
51+
return LocalPy::WindowsConda { conda_path };
5152
}
52-
log::debug!("detected windows");
53-
LocalPy::Windows
54-
} else {
55-
log::debug!("detected unix");
56-
LocalPy::Unix
5753
}
58-
};
59-
}
54+
log::debug!("detected windows");
55+
LocalPy::Windows
56+
} else {
57+
log::debug!("detected unix");
58+
LocalPy::Unix
59+
}
60+
});
6061

6162
enum LocalPy {
6263
Unix,
@@ -409,6 +410,7 @@ impl LanguagePlugin for Python3Plugin {
409410
}
410411

411412
#[cfg(test)]
413+
#[allow(clippy::clippy::unwrap_used)]
412414
mod test {
413415
use super::*;
414416
use std::{

plugins/r/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(clippy::print_stdout, clippy::print_stderr)]
1+
#![deny(clippy::print_stdout, clippy::print_stderr, clippy::unwrap_used)]
22

33
//! Language plugin for the R language
44

plugins/r/src/plugin.rs

+1
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ impl LanguagePlugin for RPlugin {
188188

189189
#[cfg(test)]
190190
#[cfg(target_os = "linux")] // tmc-r-testrunner not installed on other CI platforms
191+
#[allow(clippy::clippy::unwrap_used)]
191192
mod test {
192193
use super::*;
193194
use std::path::PathBuf;

tmc-client/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ tmc-langs-util = { path = "../tmc-langs-util" }
1212
chrono = { version = "0.4", features = ["serde"] }
1313
dirs = "3"
1414
http = "0.2"
15-
lazy_static = "1"
1615
log = "0.4"
1716
oauth2 = { version = "4.0.0-beta.1", features = ["reqwest"] }
17+
once_cell = "1"
1818
percent-encoding = "2"
1919
regex = "1"
2020
reqwest = { version = "0.11", default-features = false, features = ["blocking", "json", "rustls-tls", "multipart"] }

tmc-client/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(clippy::print_stdout, clippy::print_stderr)]
1+
#![deny(clippy::print_stdout, clippy::print_stderr, clippy::unwrap_used)]
22

33
//! Used to communicate with the TMC server. See the TmcClient struct for more details.
44
//!

tmc-client/src/response.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Contains types which model the JSON responses from tmc-server
22
33
use chrono::{DateTime, FixedOffset};
4-
use lazy_static::lazy_static;
4+
use once_cell::sync::Lazy;
55
use regex::Regex;
66
use schemars::JsonSchema;
77
use serde::{
@@ -403,9 +403,10 @@ impl<'de> Visitor<'de> for SubmissionFeedbackKindVisitor {
403403
where
404404
E: de::Error,
405405
{
406-
lazy_static! {
407-
static ref RANGE: Regex = Regex::new(r#"intrange\[(\d+)\.\.(\d+)\]"#).unwrap();
408-
}
406+
#[allow(clippy::clippy::unwrap_used)]
407+
static RANGE: Lazy<Regex> =
408+
Lazy::new(|| Regex::new(r#"intrange\[(\d+)\.\.(\d+)\]"#).unwrap());
409+
409410
if value == "text" {
410411
Ok(SubmissionFeedbackKind::Text)
411412
} else if let Some(captures) = RANGE.captures(&value) {
@@ -455,6 +456,7 @@ pub struct UpdateResult {
455456
}
456457

457458
#[cfg(test)]
459+
#[allow(clippy::clippy::unwrap_used)]
458460
mod test {
459461
use super::*;
460462

tmc-client/src/tmc_client.rs

+1
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ fn finish_stage(message: impl Into<String>, data: impl Into<Option<ClientUpdateD
634634
}
635635

636636
#[cfg(test)]
637+
#[allow(clippy::clippy::unwrap_used)]
637638
mod test {
638639
use super::*;
639640
use mockito::{mock, Matcher};

tmc-langs-cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tmc-langs-cli"
3-
version = "0.17.2"
3+
version = "0.18.0"
44
authors = ["University of Helsinki <mooc@cs.helsinki.fi>", "Daniel Martinez <daniel.x.martinez@helsinki.fi>"]
55
edition = "2018"
66
description = "CLI client for TMC"

tmc-langs-cli/src/app.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ fn schema_leaked<T: JsonSchema>() -> &'static str {
582582
let schema = schemars::schema_for!(T);
583583
let json = format!(
584584
"Result data JSON format:\n{}",
585-
serde_json::to_string_pretty(&schema).unwrap()
585+
serde_json::to_string_pretty(&schema).expect("serialization should not fail")
586586
);
587587
Box::leak(Box::new(json))
588588
}

tmc-langs-cli/src/lib.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(clippy::print_stdout, clippy::print_stderr)]
1+
#![deny(clippy::print_stdout, clippy::print_stderr, clippy::unwrap_used)]
22

33
//! CLI client for TMC
44
@@ -469,7 +469,9 @@ fn run_app(matches: Opt) -> Result<()> {
469469

470470
// todo: checkstyle results in stdout?
471471
if let Some(checkstyle_output_path) = checkstyle_output_path {
472-
let locale = locale.unwrap().0;
472+
let locale = locale
473+
.expect("locale is required if checkstyle output path is given")
474+
.0;
473475

474476
run_checkstyle_write_results(
475477
&exercise_path,
@@ -704,7 +706,9 @@ fn run_core_inner(
704706
let mut checksums = HashMap::new();
705707
while let Some(exercise_id) = exercise_checksums.next() {
706708
let exercise_id = into_usize(&exercise_id)?;
707-
let checksum = exercise_checksums.next().unwrap(); // safe unwrap due to exercise taking two values
709+
let checksum = exercise_checksums
710+
.next()
711+
.expect("the argument takes two values");
708712
checksums.insert(exercise_id, checksum.to_string());
709713
}
710714

tmc-langs-cli/src/output.rs

+1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ pub struct DownloadTarget {
158158
}
159159

160160
#[cfg(test)]
161+
#[allow(clippy::clippy::unwrap_used)]
161162
mod test {
162163
use super::*;
163164

tmc-langs-framework/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ tmc-langs-util = { path = "../tmc-langs-util" }
1010

1111
fd-lock = "2"
1212
isolang = "1"
13-
lazy_static = "1"
1413
log = "0.4"
1514
nom = { version = "6", features = ["alloc"] }
1615
once_cell = "1"

0 commit comments

Comments
 (0)