Skip to content

Commit 4e3621f

Browse files
authored
fix: integration tests NoServerForLanguage + clippy.toml msrv sync (#111)
* fix: sync clippy.toml msrv with Cargo.toml rust-version Update msrv from "1.85" to "1.88" to match workspace rust-version bumped in commit 5d938b9. Eliminates the MSRV mismatch warning on every clippy run and ensures linting targets the correct API surface. Closes #107 * fix(bridge): pass extension map to Translator in integration tests setup_rust_analyzer() called Translator::new() which initializes with an empty extension_map. detect_language() fell back to "plaintext" for .rs files, so the client registered under "rust" could not be found, causing NoServerForLanguage("plaintext") in 12 of 19 tests. Fix: chain with_extensions({"rs" => "rust"}) on the test Translator to match the registration key used in setup_rust_analyzer(). Also applies let-chain flattening (if let A && let B) across translator, config, lsp modules to remove nested if-let blocks now valid under Rust 1.88 (MSRV bump from #107). Closes #106
1 parent d527242 commit 4e3621f

7 files changed

Lines changed: 55 additions & 57 deletions

File tree

clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Clippy configuration
22
# See: https://doc.rust-lang.org/clippy/configuration.html
33

4-
msrv = "1.85"
4+
msrv = "1.88"
55
cognitive-complexity-threshold = 25

crates/mcpls-core/src/bridge/translator.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,10 @@ impl Translator {
441441

442442
// Check if path is within any workspace root
443443
for root in &self.workspace_roots {
444-
if let Ok(canonical_root) = root.canonicalize() {
445-
if canonical.starts_with(&canonical_root) {
446-
return Ok(canonical);
447-
}
444+
if let Ok(canonical_root) = root.canonicalize()
445+
&& canonical.starts_with(&canonical_root)
446+
{
447+
return Ok(canonical);
448448
}
449449
}
450450

@@ -995,15 +995,14 @@ impl Translator {
995995
}
996996

997997
// Validate kind filter
998-
if let Some(ref kind) = kind_filter {
999-
if !VALID_SYMBOL_KINDS
998+
if let Some(ref kind) = kind_filter
999+
&& !VALID_SYMBOL_KINDS
10001000
.iter()
10011001
.any(|k| k.eq_ignore_ascii_case(kind))
1002-
{
1003-
return Err(Error::InvalidToolParams(format!(
1004-
"Invalid kind_filter: '{kind}'. Valid values: {VALID_SYMBOL_KINDS:?}"
1005-
)));
1006-
}
1002+
{
1003+
return Err(Error::InvalidToolParams(format!(
1004+
"Invalid kind_filter: '{kind}'. Valid values: {VALID_SYMBOL_KINDS:?}"
1005+
)));
10071006
}
10081007

10091008
// Workspace search requires at least one LSP client
@@ -1075,15 +1074,14 @@ impl Translator {
10751074
];
10761075

10771076
// Validate kind filter
1078-
if let Some(ref kind) = kind_filter {
1079-
if !VALID_ACTION_KINDS
1077+
if let Some(ref kind) = kind_filter
1078+
&& !VALID_ACTION_KINDS
10801079
.iter()
10811080
.any(|k| k.eq_ignore_ascii_case(kind))
1082-
{
1083-
return Err(Error::InvalidToolParams(format!(
1084-
"Invalid kind_filter: '{kind}'. Valid values: {VALID_ACTION_KINDS:?}"
1085-
)));
1086-
}
1081+
{
1082+
return Err(Error::InvalidToolParams(format!(
1083+
"Invalid kind_filter: '{kind}'. Valid values: {VALID_ACTION_KINDS:?}"
1084+
)));
10871085
}
10881086

10891087
// Validate range

crates/mcpls-core/src/config/server.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,11 @@ impl ServerHeuristics {
118118
.standard_filters(false)
119119
.filter_entry(|entry| {
120120
// Skip excluded directories entirely (prevents descending into them)
121-
if entry.file_type().is_some_and(|ft| ft.is_dir()) {
122-
if let Some(name) = entry.file_name().to_str() {
123-
if EXCLUDED_DIRECTORIES.contains(&name) {
124-
return false;
125-
}
126-
}
121+
if entry.file_type().is_some_and(|ft| ft.is_dir())
122+
&& let Some(name) = entry.file_name().to_str()
123+
&& EXCLUDED_DIRECTORIES.contains(&name)
124+
{
125+
return false;
127126
}
128127
true
129128
});
@@ -132,10 +131,10 @@ impl ServerHeuristics {
132131
let path = entry.path();
133132

134133
// Check if this entry matches any marker
135-
if let Some(file_name) = path.file_name().and_then(|n| n.to_str()) {
136-
if self.project_markers.iter().any(|m| m == file_name) {
137-
return true;
138-
}
134+
if let Some(file_name) = path.file_name().and_then(|n| n.to_str())
135+
&& self.project_markers.iter().any(|m| m == file_name)
136+
{
137+
return true;
139138
}
140139
}
141140

crates/mcpls-core/src/lsp/client.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -620,13 +620,13 @@ mod tests {
620620
};
621621

622622
let sender = pending_requests.lock().await.remove(&error_response.id);
623-
if let Some(sender) = sender {
624-
if let Some(error) = error_response.error {
625-
let _ = sender.send(Err(Error::LspServerError {
626-
code: error.code,
627-
message: error.message,
628-
}));
629-
}
623+
if let Some(sender) = sender
624+
&& let Some(error) = error_response.error
625+
{
626+
let _ = sender.send(Err(Error::LspServerError {
627+
code: error.code,
628+
message: error.message,
629+
}));
630630
}
631631

632632
let result = response_rx.await.unwrap();
@@ -682,13 +682,13 @@ mod tests {
682682
};
683683

684684
let sender = pending_requests.lock().await.remove(&error_response.id);
685-
if let Some(sender) = sender {
686-
if let Some(error) = error_response.error {
687-
let _ = sender.send(Err(Error::LspServerError {
688-
code: error.code,
689-
message: error.message,
690-
}));
691-
}
685+
if let Some(sender) = sender
686+
&& let Some(error) = error_response.error
687+
{
688+
let _ = sender.send(Err(Error::LspServerError {
689+
code: error.code,
690+
message: error.message,
691+
}));
692692
}
693693

694694
let result = response_rx.await.unwrap();

crates/mcpls-core/src/lsp/lifecycle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl ServerInitResult {
139139

140140
/// Get the number of failures.
141141
#[must_use]
142-
pub fn failure_count(&self) -> usize {
142+
pub const fn failure_count(&self) -> usize {
143143
self.failures.len()
144144
}
145145

crates/mcpls-core/src/lsp/types.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,32 +137,32 @@ impl LspNotification {
137137
pub fn parse(method: &str, params: Option<serde_json::Value>) -> Self {
138138
match method {
139139
"textDocument/publishDiagnostics" => {
140-
if let Some(p) = params {
141-
if let Ok(parsed) = serde_json::from_value(p) {
142-
return Self::PublishDiagnostics(parsed);
143-
}
140+
if let Some(p) = params
141+
&& let Ok(parsed) = serde_json::from_value(p)
142+
{
143+
return Self::PublishDiagnostics(parsed);
144144
}
145145
Self::Other {
146146
method: Cow::Owned(method.to_string()),
147147
params: None,
148148
}
149149
}
150150
"window/logMessage" => {
151-
if let Some(p) = params {
152-
if let Ok(parsed) = serde_json::from_value(p) {
153-
return Self::LogMessage(parsed);
154-
}
151+
if let Some(p) = params
152+
&& let Ok(parsed) = serde_json::from_value(p)
153+
{
154+
return Self::LogMessage(parsed);
155155
}
156156
Self::Other {
157157
method: Cow::Owned(method.to_string()),
158158
params: None,
159159
}
160160
}
161161
"window/showMessage" => {
162-
if let Some(p) = params {
163-
if let Ok(parsed) = serde_json::from_value(p) {
164-
return Self::ShowMessage(parsed);
165-
}
162+
if let Some(p) = params
163+
&& let Ok(parsed) = serde_json::from_value(p)
164+
{
165+
return Self::ShowMessage(parsed);
166166
}
167167
Self::Other {
168168
method: Cow::Owned(method.to_string()),

crates/mcpls-core/tests/integration/rust_analyzer_tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ async fn setup_rust_analyzer() -> Arc<Mutex<Translator>> {
6969

7070
let client = server.client().clone();
7171

72-
let mut translator = Translator::new();
72+
let extension_map = std::collections::HashMap::from([("rs".to_string(), "rust".to_string())]);
73+
let mut translator = Translator::new().with_extensions(extension_map);
7374
translator.set_workspace_roots(vec![workspace_path]);
7475
translator.register_client("rust".to_string(), client);
7576
translator.register_server("rust".to_string(), server);

0 commit comments

Comments
 (0)