Skip to content

Commit 5de30da

Browse files
authored
Merge pull request #123 from rage/more-refactoring
More refactoring
2 parents 8a96a6c + 3a91d3d commit 5de30da

File tree

36 files changed

+807
-1840
lines changed

36 files changed

+807
-1840
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ cargo run -p tmc-langs-cli help
3838

3939
## Development
4040

41-
Format using `cargo fmt`, use `cargo clippy` for linting.
41+
Format using `cargo fmt`, use `cargo clippy` for linting. All crates should have the clippy lints `print_stdout` and `print_stderr` set to deny. The CLI has one function where writing to stdout is allowed.
4242

4343
If using vscode and rust-analyzer, be sure to turn on the setting `loadOutDirsFromCheck` to avoid a spurious unresolved import error from `isolang`.
4444

plugins/csharp/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(clippy::print_stdout, clippy::print_stderr)]
2+
13
//! TMC language plugin for C#.
24
35
mod cs_test_result;

plugins/csharp/src/plugin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ mod test {
686686
}
687687

688688
#[test]
689-
#[ignore = "requires newer version of C# runner that always includes all points in the tests"]
689+
// #[ignore = "requires newer version of C# runner that always includes all points in the tests"]
690690
fn doesnt_give_points_unless_all_relevant_exercises_pass() {
691691
init();
692692

plugins/java/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(clippy::print_stdout, clippy::print_stderr)]
2+
13
//! Java plugins for ant and maven
24
35
mod ant_plugin;

plugins/make/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(clippy::print_stdout, clippy::print_stderr)]
2+
13
//! TMC plugin for make.
24
35
mod check_log;

plugins/notests/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(clippy::print_stdout, clippy::print_stderr, clippy::unwrap_used)]
2+
13
//! Language plugin for no_tests exercises.
24
35
mod plugin;

plugins/python3/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(clippy::print_stdout, clippy::print_stderr)]
2+
13
//! Implementation of LanguagePlugin for Python 3.
24
35
mod error;

plugins/r/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(clippy::print_stdout, clippy::print_stderr)]
2+
13
//! Language plugin for the R language
24
35
mod error;

tmc-client/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(clippy::print_stdout, clippy::print_stderr)]
2+
13
//! Used to communicate with the TMC server. See the TmcClient struct for more details.
24
//!
35
//! ```rust,no_run

tmc-client/src/tmc_client.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@ impl TmcClient {
225225
None,
226226
);
227227

228+
// for each exercise, check if there's already something on disk
229+
// if yes, check if it needs updating
230+
// if not, check if there's a previous submission
231+
// if yes, download it
232+
// if not, download the exercise template
233+
228234
let thread_count = exercises_len.min(4); // max 4 threads
229235
let mut handles = vec![];
230236
let exercises = Arc::new(Mutex::new(exercises));
@@ -248,7 +254,7 @@ impl TmcClient {
248254
// repeat until out of exercises
249255
loop {
250256
// acquiring mutex
251-
let mut exercises = exercises.lock().unwrap(); // the threads should never panic
257+
let mut exercises = exercises.lock().expect("the threads should never panic");
252258
let (exercise_id, target) = if let Some((id, path)) = exercises.pop() {
253259
(id, path)
254260
} else {
@@ -319,8 +325,7 @@ impl TmcClient {
319325
let mut successful = vec![];
320326
let mut failed = vec![];
321327
for handle in handles {
322-
// the threads should never panic
323-
match handle.join().unwrap() {
328+
match handle.join().expect("the threads should never panic") {
324329
Ok(s) => successful.extend(s),
325330
Err((s, f)) => {
326331
successful.extend(s);
@@ -370,7 +375,7 @@ impl TmcClient {
370375

371376
pub fn get_exercises_details(
372377
&self,
373-
exercise_ids: Vec<usize>,
378+
exercise_ids: &[usize],
374379
) -> Result<Vec<ExercisesDetails>, ClientError> {
375380
self.core_exercise_details(exercise_ids)
376381
}

0 commit comments

Comments
 (0)