Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Clippy configuration
# See: https://doc.rust-lang.org/clippy/configuration.html

msrv = "1.85"
msrv = "1.88"
cognitive-complexity-threshold = 25
34 changes: 16 additions & 18 deletions crates/mcpls-core/src/bridge/translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,10 @@ impl Translator {

// Check if path is within any workspace root
for root in &self.workspace_roots {
if let Ok(canonical_root) = root.canonicalize() {
if canonical.starts_with(&canonical_root) {
return Ok(canonical);
}
if let Ok(canonical_root) = root.canonicalize()
&& canonical.starts_with(&canonical_root)
{
return Ok(canonical);
}
}

Expand Down Expand Up @@ -995,15 +995,14 @@ impl Translator {
}

// Validate kind filter
if let Some(ref kind) = kind_filter {
if !VALID_SYMBOL_KINDS
if let Some(ref kind) = kind_filter
&& !VALID_SYMBOL_KINDS
.iter()
.any(|k| k.eq_ignore_ascii_case(kind))
{
return Err(Error::InvalidToolParams(format!(
"Invalid kind_filter: '{kind}'. Valid values: {VALID_SYMBOL_KINDS:?}"
)));
}
{
return Err(Error::InvalidToolParams(format!(
"Invalid kind_filter: '{kind}'. Valid values: {VALID_SYMBOL_KINDS:?}"
)));
}

// Workspace search requires at least one LSP client
Expand Down Expand Up @@ -1075,15 +1074,14 @@ impl Translator {
];

// Validate kind filter
if let Some(ref kind) = kind_filter {
if !VALID_ACTION_KINDS
if let Some(ref kind) = kind_filter
&& !VALID_ACTION_KINDS
.iter()
.any(|k| k.eq_ignore_ascii_case(kind))
{
return Err(Error::InvalidToolParams(format!(
"Invalid kind_filter: '{kind}'. Valid values: {VALID_ACTION_KINDS:?}"
)));
}
{
return Err(Error::InvalidToolParams(format!(
"Invalid kind_filter: '{kind}'. Valid values: {VALID_ACTION_KINDS:?}"
)));
}

// Validate range
Expand Down
19 changes: 9 additions & 10 deletions crates/mcpls-core/src/config/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,11 @@ impl ServerHeuristics {
.standard_filters(false)
.filter_entry(|entry| {
// Skip excluded directories entirely (prevents descending into them)
if entry.file_type().is_some_and(|ft| ft.is_dir()) {
if let Some(name) = entry.file_name().to_str() {
if EXCLUDED_DIRECTORIES.contains(&name) {
return false;
}
}
if entry.file_type().is_some_and(|ft| ft.is_dir())
&& let Some(name) = entry.file_name().to_str()
&& EXCLUDED_DIRECTORIES.contains(&name)
{
return false;
}
true
});
Expand All @@ -132,10 +131,10 @@ impl ServerHeuristics {
let path = entry.path();

// Check if this entry matches any marker
if let Some(file_name) = path.file_name().and_then(|n| n.to_str()) {
if self.project_markers.iter().any(|m| m == file_name) {
return true;
}
if let Some(file_name) = path.file_name().and_then(|n| n.to_str())
&& self.project_markers.iter().any(|m| m == file_name)
{
return true;
}
}

Expand Down
28 changes: 14 additions & 14 deletions crates/mcpls-core/src/lsp/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,13 +620,13 @@ mod tests {
};

let sender = pending_requests.lock().await.remove(&error_response.id);
if let Some(sender) = sender {
if let Some(error) = error_response.error {
let _ = sender.send(Err(Error::LspServerError {
code: error.code,
message: error.message,
}));
}
if let Some(sender) = sender
&& let Some(error) = error_response.error
{
let _ = sender.send(Err(Error::LspServerError {
code: error.code,
message: error.message,
}));
}

let result = response_rx.await.unwrap();
Expand Down Expand Up @@ -682,13 +682,13 @@ mod tests {
};

let sender = pending_requests.lock().await.remove(&error_response.id);
if let Some(sender) = sender {
if let Some(error) = error_response.error {
let _ = sender.send(Err(Error::LspServerError {
code: error.code,
message: error.message,
}));
}
if let Some(sender) = sender
&& let Some(error) = error_response.error
{
let _ = sender.send(Err(Error::LspServerError {
code: error.code,
message: error.message,
}));
}

let result = response_rx.await.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/mcpls-core/src/lsp/lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl ServerInitResult {

/// Get the number of failures.
#[must_use]
pub fn failure_count(&self) -> usize {
pub const fn failure_count(&self) -> usize {
self.failures.len()
}

Expand Down
24 changes: 12 additions & 12 deletions crates/mcpls-core/src/lsp/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,32 +137,32 @@ impl LspNotification {
pub fn parse(method: &str, params: Option<serde_json::Value>) -> Self {
match method {
"textDocument/publishDiagnostics" => {
if let Some(p) = params {
if let Ok(parsed) = serde_json::from_value(p) {
return Self::PublishDiagnostics(parsed);
}
if let Some(p) = params
&& let Ok(parsed) = serde_json::from_value(p)
{
return Self::PublishDiagnostics(parsed);
}
Self::Other {
method: Cow::Owned(method.to_string()),
params: None,
}
}
"window/logMessage" => {
if let Some(p) = params {
if let Ok(parsed) = serde_json::from_value(p) {
return Self::LogMessage(parsed);
}
if let Some(p) = params
&& let Ok(parsed) = serde_json::from_value(p)
{
return Self::LogMessage(parsed);
}
Self::Other {
method: Cow::Owned(method.to_string()),
params: None,
}
}
"window/showMessage" => {
if let Some(p) = params {
if let Ok(parsed) = serde_json::from_value(p) {
return Self::ShowMessage(parsed);
}
if let Some(p) = params
&& let Ok(parsed) = serde_json::from_value(p)
{
return Self::ShowMessage(parsed);
}
Self::Other {
method: Cow::Owned(method.to_string()),
Expand Down
3 changes: 2 additions & 1 deletion crates/mcpls-core/tests/integration/rust_analyzer_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ async fn setup_rust_analyzer() -> Arc<Mutex<Translator>> {

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

let mut translator = Translator::new();
let extension_map = std::collections::HashMap::from([("rs".to_string(), "rust".to_string())]);
let mut translator = Translator::new().with_extensions(extension_map);
translator.set_workspace_roots(vec![workspace_path]);
translator.register_client("rust".to_string(), client);
translator.register_server("rust".to_string(), server);
Expand Down
Loading