Skip to content

Commit fcc48d5

Browse files
committed
Clippy, fmt, generate
1 parent b4ad694 commit fcc48d5

File tree

11 files changed

+239
-77
lines changed

11 files changed

+239
-77
lines changed

Cargo.lock

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings/tmc-langs-node/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ version = "1.0.0"
1818

1919
[dependencies]
2020
tmc-langs = { workspace = true, features = ["ts-rs"] }
21+
tmc-langs-util = { workspace = true }
2122

2223
base64 = "0.22.0"
2324
env_logger = "0.11.2"

crates/bindings/tmc-langs-node/src/de.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use serde::de::{
1010
pub fn from_value<'j, C, T>(cx: &mut C, value: Handle<'j, JsValue>) -> LibResult<T>
1111
where
1212
C: Context<'j>,
13-
T: DeserializeOwned + ?Sized,
13+
T: DeserializeOwned,
1414
{
1515
let mut deserializer: Deserializer<C> = Deserializer::new(cx, value);
1616
let t = T::deserialize(&mut deserializer)?;

crates/bindings/tmc-langs-node/src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ macro_rules! lock {
99
( $cx: ident, $( $path: expr ),+ ) => {
1010
$(
1111
let path_buf: PathBuf = (&$path).into();
12-
let mut lock = $crate::file_util::Lock::file(path_buf, $crate::file_util::LockOptions::Write).map_err(|e| $crate::helpers::convert_err(&mut $cx, e))?;
12+
let mut lock = ::tmc_langs_util::file_util::Lock::file(path_buf, ::tmc_langs_util::file_util::LockOptions::Write).map_err(|e| $crate::helpers::convert_err(&mut $cx, e))?;
1313
let _guard = lock.lock().map_err(|e| $crate::helpers::convert_err(&mut $cx, e))?;
1414
)*
1515
};

crates/bindings/tmc-langs-node/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use std::{
1616
};
1717
use thiserror::Error;
1818
use tmc_langs::{
19-
file_util,
2019
tmc::{
2120
request::FeedbackAnswer,
2221
response::{NewSubmission, SubmissionFinished},
@@ -25,6 +24,7 @@ use tmc_langs::{
2524
Compression, Credentials, DownloadOrUpdateCourseExercisesResult, LangsError, Language,
2625
PrepareSubmission, TmcConfig,
2726
};
27+
use tmc_langs_util::file_util;
2828

2929
#[derive(Debug, Error)]
3030
enum NodeError {
@@ -135,7 +135,7 @@ fn extract_project(mut cx: FunctionContext) -> JsResult<JsValue> {
135135
);
136136

137137
let mut archive_lock = file_util::Lock::file(archive_path, file_util::LockOptions::Read)
138-
.map_err(|e| convert_err(&mut cx, e))?;
138+
.map_err(|e: tmc_langs_util::FileError| convert_err(&mut cx, e))?;
139139
let mut archive_guard = archive_lock.lock().map_err(|e| convert_err(&mut cx, e))?;
140140
let mut data = vec![];
141141
archive_guard

crates/bindings/tmc-langs-node/ts/generated.d.ts

Lines changed: 222 additions & 54 deletions
Large diffs are not rendered by default.

crates/tmc-langs-cli/src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,19 @@ use serde_json::Value;
2020
use std::{
2121
collections::HashMap,
2222
env,
23-
fs::File,
2423
io::{self, BufReader, Cursor, Read},
25-
ops::Deref,
2624
path::{Path, PathBuf},
2725
};
2826
use tmc_langs::{
29-
file_util::{self, Lock, LockOptions},
30-
file_util,
3127
mooc::MoocClient,
3228
tmc::{request::FeedbackAnswer, TestMyCodeClient, TestMyCodeClientError},
3329
CommandError, Compression, Credentials, DownloadOrUpdateCourseExercisesResult, DownloadResult,
3430
Language, StyleValidationResult, TmcConfig, UpdatedExercise,
3531
};
36-
use tmc_langs_util::deserialize;
32+
use tmc_langs_util::{
33+
deserialize,
34+
file_util::{self, Lock, LockOptions},
35+
};
3736

3837
pub enum ParsingResult {
3938
Ok(Cli),

crates/tmc-langs-util/src/file_util/lock_unix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl Lock {
9595
FileOrLock::File(file)
9696
}
9797
};
98-
Ok(Guard { lock, path: &path })
98+
Ok(Guard { lock, path })
9999
}
100100
}
101101

crates/tmc-langs/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ pub fn migrate_exercise(
7373
exercise_path.display()
7474
);
7575

76-
let mut lock = Lock::dir(exercise_path.to_path_buf(), LockOptions::Write)?;
77-
let guard = lock.lock()?;
76+
let mut lock = Lock::dir(exercise_path, LockOptions::Write)?;
77+
let _guard = lock.lock()?;
7878
let mut projects_config = ProjectsConfig::load(&tmc_config.projects_dir)?;
7979
let course_config = projects_config
8080
.courses

crates/tmc-langs/src/config/projects_config.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use tmc_langs_util::{
1111
file_util::{self, Lock, LockOptions},
1212
FileError,
1313
};
14-
use uuid::Uuid;
1514
use walkdir::WalkDir;
1615

1716
/// A project directory is a directory which contains directories of courses (which contain a `course_config.toml`).
@@ -32,7 +31,7 @@ impl ProjectsConfig {
3231
let mut unexpected_entries = Vec::new();
3332
for entry in WalkDir::new(projects_dir).min_depth(1).max_depth(1) {
3433
let entry = entry?;
35-
let course_config_path = entry.path().join("course_config.toml");
34+
let course_config_path = entry.path().join(COURSE_CONFIG_FILE_NAME);
3635
if course_config_path.exists() {
3736
let file_name = entry.file_name();
3837
let course_dir_name = file_name.to_str().ok_or_else(|| {
@@ -146,7 +145,7 @@ impl CourseConfig {
146145
if !course_dir.exists() {
147146
file_util::create_dir_all(&course_dir)?;
148147
}
149-
let target = course_dir.join("course_config.toml");
148+
let target = course_dir.join(COURSE_CONFIG_FILE_NAME);
150149
let s = toml::to_string_pretty(&self)?;
151150
file_util::write_to_file(s.as_bytes(), target)?;
152151
Ok(())

0 commit comments

Comments
 (0)