Skip to content

Commit 0bf9ad1

Browse files
committed
method to associated constant, clippy lints
1 parent ea0c599 commit 0bf9ad1

File tree

9 files changed

+16
-43
lines changed

9 files changed

+16
-43
lines changed

tmc-langs-framework/src/io/submission_processing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use lazy_static::lazy_static;
88
use log::{debug, info};
99
use regex::Regex;
1010
use std::fs::{self, File};
11-
use std::io::{BufWriter, Write};
11+
use std::io::Write;
1212
use std::path::{Path, PathBuf};
1313
use walkdir::{DirEntry, WalkDir};
1414

tmc-langs-framework/src/plugin.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ use walkdir::WalkDir;
2626
/// Implementations must be thread-safe and preferably fully stateless. Users of
2727
/// this interface are free to cache results if needed.
2828
pub trait LanguagePlugin {
29+
const PLUGIN_NAME: &'static str;
2930
type StudentFilePolicy: StudentFilePolicy + 'static;
3031

31-
/// Returns the name of the plug-in.
32-
fn get_plugin_name() -> &'static str;
33-
3432
/// Returns a list of all directories inside that contain an exercise in this
3533
/// language.
3634
///
@@ -207,16 +205,13 @@ mod test {
207205
}
208206

209207
impl LanguagePlugin for MockPlugin {
208+
const PLUGIN_NAME: &'static str = "mock_plugin";
210209
type StudentFilePolicy = MockPolicy;
211210

212211
fn get_student_file_policy(project_path: &Path) -> Self::StudentFilePolicy {
213212
unimplemented!()
214213
}
215214

216-
fn get_plugin_name() -> &'static str {
217-
unimplemented!()
218-
}
219-
220215
fn scan_exercise(&self, _path: &Path, _exercise_name: String) -> Result<ExerciseDesc> {
221216
unimplemented!()
222217
}

tmc-langs-java/src/ant.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use std::time::Duration;
1515
use tmc_langs_framework::{
1616
domain::{ExerciseDesc, RunResult},
1717
plugin::{Language, LanguagePlugin, ValidationResult},
18-
policy::StudentFilePolicy,
1918
Error,
2019
};
2120
use walkdir::WalkDir;
@@ -71,12 +70,9 @@ impl AntPlugin {
7170
}
7271

7372
impl LanguagePlugin for AntPlugin {
73+
const PLUGIN_NAME: &'static str = "apache-ant";
7474
type StudentFilePolicy = AntStudentFilePolicy;
7575

76-
fn get_plugin_name() -> &'static str {
77-
"apache-ant"
78-
}
79-
8076
fn check_code_style(&self, path: &Path, locale: Language) -> Option<ValidationResult> {
8177
self.run_checkstyle(&locale, path)
8278
}

tmc-langs-java/src/maven.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use tar::Archive;
1717
use tmc_langs_framework::{
1818
domain::{ExerciseDesc, RunResult},
1919
plugin::{Language, LanguagePlugin, ValidationResult},
20-
policy::StudentFilePolicy,
2120
Error,
2221
};
2322

@@ -73,12 +72,9 @@ impl MavenPlugin {
7372
}
7473

7574
impl LanguagePlugin for MavenPlugin {
75+
const PLUGIN_NAME: &'static str = "apache-maven";
7676
type StudentFilePolicy = MavenStudentFilePolicy;
7777

78-
fn get_plugin_name() -> &'static str {
79-
"apache-maven"
80-
}
81-
8278
fn check_code_style(&self, path: &Path, locale: Language) -> Option<ValidationResult> {
8379
self.run_checkstyle(&locale, path)
8480
}

tmc-langs-make/src/plugin.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use std::time::Duration;
1717
use tmc_langs_framework::{
1818
domain::{ExerciseDesc, RunResult, RunStatus, TestDesc, TmcProjectYml},
1919
plugin::LanguagePlugin,
20-
policy::StudentFilePolicy,
2120
Error,
2221
};
2322

@@ -117,12 +116,9 @@ impl MakePlugin {
117116
}
118117

119118
impl LanguagePlugin for MakePlugin {
119+
const PLUGIN_NAME: &'static str = "make";
120120
type StudentFilePolicy = MakeStudentFilePolicy;
121121

122-
fn get_plugin_name() -> &'static str {
123-
"make"
124-
}
125-
126122
fn scan_exercise(&self, path: &Path, exercise_name: String) -> Result<ExerciseDesc, Error> {
127123
if !Self::is_exercise_type_correct(path) {
128124
return MakeError::NoExerciseFound.into();

tmc-langs-notests/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,9 @@ impl NoTestsPlugin {
2727
}
2828

2929
impl LanguagePlugin for NoTestsPlugin {
30+
const PLUGIN_NAME: &'static str = "No-Tests";
3031
type StudentFilePolicy = EverythingIsStudentFilePolicy;
3132

32-
fn get_plugin_name() -> &'static str {
33-
"No-Tests"
34-
}
35-
3633
fn scan_exercise(&self, path: &Path, exercise_name: String) -> Result<ExerciseDesc, Error> {
3734
let test_name = format!("{}Test", exercise_name);
3835
Ok(ExerciseDesc {

tmc-langs-python3/src/plugin.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use std::time::Duration;
1313
use tmc_langs_framework::{
1414
domain::{ExerciseDesc, RunResult, RunStatus, TestDesc, TestResult},
1515
plugin::LanguagePlugin,
16-
policy::StudentFilePolicy,
1716
CommandWithTimeout, Error,
1817
};
1918
use walkdir::WalkDir;
@@ -27,12 +26,9 @@ impl Python3Plugin {
2726
}
2827

2928
impl LanguagePlugin for Python3Plugin {
29+
const PLUGIN_NAME: &'static str = "python3";
3030
type StudentFilePolicy = Python3StudentFilePolicy;
3131

32-
fn get_plugin_name() -> &'static str {
33-
"python3"
34-
}
35-
3632
fn get_student_file_policy(project_path: &Path) -> Self::StudentFilePolicy {
3733
Python3StudentFilePolicy::new(project_path.to_owned())
3834
}

tmc-langs-r/src/plugin.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use super::RRunResult;
77

88
use tmc_langs_framework::{
99
domain::{ExerciseDesc, RunResult, TestDesc},
10-
Error, LanguagePlugin, StudentFilePolicy,
10+
Error, LanguagePlugin,
1111
};
1212

1313
use std::collections::HashMap;
@@ -25,12 +25,9 @@ impl RPlugin {
2525
}
2626

2727
impl LanguagePlugin for RPlugin {
28+
const PLUGIN_NAME: &'static str = "r";
2829
type StudentFilePolicy = RStudentFilePolicy;
2930

30-
fn get_plugin_name() -> &'static str {
31-
"r"
32-
}
33-
3431
fn scan_exercise(&self, path: &Path, exercise_name: String) -> Result<ExerciseDesc, Error> {
3532
// run available points command
3633
let args = if cfg!(windows) {

tmc-langs-util/src/task_executor.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,23 +234,23 @@ impl Plugin {
234234
fn get_language_plugin(path: &Path) -> Result<Plugin, Error> {
235235
if MakePlugin::is_exercise_type_correct(path) {
236236
let make = MakePlugin::new();
237-
info!("Detected project as {}", MakePlugin::get_plugin_name());
237+
info!("Detected project as {}", MakePlugin::PLUGIN_NAME);
238238
Ok(Plugin::Make(make))
239239
} else if NoTestsPlugin::is_exercise_type_correct(path) {
240-
info!("Detected project as {}", NoTestsPlugin::get_plugin_name());
240+
info!("Detected project as {}", NoTestsPlugin::PLUGIN_NAME);
241241
Ok(Plugin::NoTests(NoTestsPlugin::new()))
242242
} else if Python3Plugin::is_exercise_type_correct(path) {
243-
info!("Detected project as {}", Python3Plugin::get_plugin_name());
243+
info!("Detected project as {}", Python3Plugin::PLUGIN_NAME);
244244
Ok(Plugin::Python3(Python3Plugin::new()))
245245
} else if RPlugin::is_exercise_type_correct(path) {
246-
info!("Detected project as {}", RPlugin::get_plugin_name());
246+
info!("Detected project as {}", RPlugin::PLUGIN_NAME);
247247
Ok(Plugin::R(RPlugin::new()))
248248
} else if MavenPlugin::is_exercise_type_correct(path) {
249-
info!("Detected project as {}", MavenPlugin::get_plugin_name());
249+
info!("Detected project as {}", MavenPlugin::PLUGIN_NAME);
250250
Ok(Plugin::Maven(MavenPlugin::new()?))
251251
} else if AntPlugin::is_exercise_type_correct(path) {
252252
// TODO: currently, ant needs to be last because any project with src and test are recognized as ant
253-
info!("Detected project as {}", AntPlugin::get_plugin_name());
253+
info!("Detected project as {}", AntPlugin::PLUGIN_NAME);
254254
Ok(Plugin::Ant(AntPlugin::new()?))
255255
} else {
256256
Err(Error::PluginNotFound(path.to_path_buf()))

0 commit comments

Comments
 (0)