Skip to content

Commit 1dc61fb

Browse files
committed
[IMP] rm cargo warnings
1 parent 9b76caa commit 1dc61fb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+224
-259
lines changed

server/benches/iai_profiler.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
use lsp_server::Notification;
22
use serde_json::json;
3-
use odoo_ls_server::{args::{Cli, LogLevel}, cli_backend::CliBackend, constants::*, server::Server, utils::PathSanitizer};
4-
use clap::Parser;
3+
use odoo_ls_server::{args::LogLevel, constants::*, server::Server, utils::PathSanitizer};
54
use tracing::{info, Level};
65
use tracing_appender::rolling::{RollingFileAppender, Rotation};
76
use tracing_panic::panic_hook;
87
use tracing_subscriber::{fmt, FmtSubscriber, layer::SubscriberExt};
98

10-
use std::{env, path::PathBuf};
9+
use std::env;
1110

1211
use iai_callgrind::{
1312
library_benchmark, library_benchmark_group, main, LibraryBenchmarkConfig,
@@ -38,7 +37,7 @@ fn iai_main() {
3837
let mut exe_dir = env::current_exe().expect("Unable to get binary directory... aborting");
3938
exe_dir.pop();
4039

41-
let mut log_dir = exe_dir.join("logs").sanitize();
40+
let log_dir = exe_dir.join("logs").sanitize();
4241

4342
let file_appender = RollingFileAppender::builder()
4443
.max_log_files(5) // only the most recent 5 log files will be kept

server/src/constants.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![allow(non_camel_case_types)]
22
use core::fmt;
33

4-
use byteyarn::{yarn, Yarn};
54

65
pub const EXTENSION_NAME: &str = "Odoo";
76
pub const EXTENSION_VERSION: &str = "0.12.0";
@@ -35,6 +34,8 @@ macro_rules! oyarn {
3534
#[cfg(all(feature="debug_yarn", debug_assertions))]
3635
pub type OYarn = String;
3736
#[cfg(not(all(feature="debug_yarn", debug_assertions)))]
37+
use byteyarn::Yarn;
38+
#[cfg(not(all(feature="debug_yarn", debug_assertions)))]
3839
pub type OYarn = Yarn;
3940

4041
pub fn tree(a: Vec<&str>, b: Vec<&str>) -> Tree {

server/src/core/csv_arch_builder.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use std::{cell::RefCell, fs::File, path::PathBuf, rc::{Rc, Weak}};
1+
use std::{cell::RefCell, path::PathBuf, rc::{Rc, Weak}};
22

3-
use csv::{StringRecord, StringRecordIter};
4-
use lsp_types::{Diagnostic, Position, Range};
3+
use csv::StringRecord;
4+
use lsp_types::Diagnostic;
55
use weak_table::PtrWeakHashSet;
66

7-
use crate::{constants::{BuildStatus, BuildSteps, OYarn}, core::{file_mgr::FileInfo, xml_data::{OdooData, OdooDataField, OdooDataRecord}}, oyarn, threads::SessionInfo, Sy, S};
7+
use crate::{constants::{BuildStatus, BuildSteps, OYarn}, core::xml_data::{OdooData, OdooDataField, OdooDataRecord}, oyarn, threads::SessionInfo, Sy};
88

99
use super::{symbols::{symbol::Symbol}};
1010

@@ -19,7 +19,7 @@ impl CsvArchBuilder {
1919
}
2020

2121
pub fn load_csv(&mut self, session: &mut SessionInfo, csv_symbol: Rc<RefCell<Symbol>>, content: &String) -> Vec<Diagnostic> {
22-
let mut diagnostics = vec![];
22+
let diagnostics = vec![];
2323
csv_symbol.borrow_mut().set_build_status(BuildSteps::ARCH, BuildStatus::IN_PROGRESS);
2424
let model_name_pb = PathBuf::from(&csv_symbol.borrow().paths()[0]);
2525
let model_name = Sy!(model_name_pb.file_stem().unwrap().to_str().unwrap().to_string());
@@ -32,7 +32,7 @@ impl CsvArchBuilder {
3232
let csv = csv_sym.as_csv_file_sym_mut();
3333
let mut rdr = csv::Reader::from_reader(content.as_bytes());
3434
if rdr.has_headers() {
35-
for header in rdr.headers() {
35+
if let Ok(header) = rdr.headers() {
3636
for h in header.iter() {
3737
csv.headers.push(oyarn!("{}", h));
3838
}
@@ -42,14 +42,13 @@ impl CsvArchBuilder {
4242
for result in rdr.records() {
4343
if let Ok(result) = result {
4444
let record = self.extract_record(Rc::downgrade(&csv_symbol), model_name.clone(), &csv.headers, &result);
45-
if let Some(mut record) = record {
45+
if let Some(record) = record {
4646
if let Some(xml_id) = record.xml_id.as_ref() {
4747
let id_split = xml_id.split(".").collect::<Vec<&str>>();
4848
if id_split.len() > 2 {
4949
//TODO diagnostic
5050
continue;
5151
}
52-
let id = id_split.last().unwrap().to_string();
5352
let mut csv_module = csv_module.clone();
5453
if id_split.len() == 2 {
5554
let module_name = Sy!(id_split.first().unwrap().to_string());

server/src/core/entry_point.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use std::{cell::RefCell, cmp, collections::HashMap, path::{self, PathBuf}, rc::{Rc, Weak}, u32};
1+
use std::{cell::RefCell, cmp, collections::HashMap, path::PathBuf, rc::{Rc, Weak}, u32};
22

3-
use byteyarn::Yarn;
43
use tracing::{error, info, warn};
54
use weak_table::PtrWeakHashSet;
65

server/src/core/evaluation.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ impl Evaluation {
328328
}
329329
}
330330

331-
pub fn new_domain(odoo: &mut SyncOdoo) -> Evaluation {
331+
pub fn new_domain(_odoo: &mut SyncOdoo) -> Evaluation {
332332
Evaluation {
333333
symbol: EvaluationSymbol {
334334
sym: EvaluationSymbolPtr::DOMAIN,
@@ -438,7 +438,7 @@ impl Evaluation {
438438
EvaluationSymbolPtr::WEAK(_) => {
439439
//take the weak by get_symbol instead of the match
440440
let symbol_eval = self.symbol.get_symbol(session, &mut None, &mut vec![], Some(function.clone()));
441-
let out_of_scope = Symbol::follow_ref(&symbol_eval, session, &mut None, false, false, Some(function.clone()), &mut vec![]);
441+
let out_of_scope = Symbol::follow_ref(&symbol_eval, session, &mut None, false, false, Some(function.clone()));
442442
for sym in out_of_scope {
443443
if !sym.is_expired_if_weak() {
444444
res.push(Evaluation {
@@ -467,7 +467,7 @@ impl Evaluation {
467467
if eval_symbol.is_expired_if_weak() {
468468
return None;
469469
}
470-
let evals = Symbol::follow_ref(&eval_symbol, session, context, false, true, None, diagnostics);
470+
let evals = Symbol::follow_ref(&eval_symbol, session, context, false, true, None);
471471
if evals.len() == 1 {
472472
let eval = &evals[0];
473473
match eval {
@@ -771,7 +771,7 @@ impl Evaluation {
771771
}
772772
let base_eval_ptrs: Vec<EvaluationSymbolPtr> = base_evals.iter().map(|base_eval| {
773773
let base_sym_weak_eval_base = base_eval.symbol.get_symbol_weak_transformed(session, context, &mut diagnostics, None);
774-
Symbol::follow_ref(&base_sym_weak_eval_base, session, context, true, false, None, &mut diagnostics)
774+
Symbol::follow_ref(&base_sym_weak_eval_base, session, context, true, false, None)
775775
}).flatten().collect();
776776

777777
let parent_file_or_func = parent.clone().borrow().parent_file_or_function().as_ref().unwrap().upgrade().unwrap();
@@ -802,7 +802,7 @@ impl Evaluation {
802802
let res = class_sym_weak_eval.weak.upgrade().and_then(|class_sym|{
803803
let class_sym_weak_eval = &Symbol::follow_ref(&&EvaluationSymbolPtr::WEAK(EvaluationSymbolWeak::new(
804804
Rc::downgrade(&class_sym), None, false
805-
)), session, &mut None, false, false, None, &mut diagnostics)[0];
805+
)), session, &mut None, false, false, None)[0];
806806
if class_sym_weak_eval.upgrade_weak().unwrap().borrow().typ() != SymType::CLASS{
807807
return None;
808808
}
@@ -831,7 +831,7 @@ impl Evaluation {
831831
let object_or_type_weak_eval = &Symbol::follow_ref(
832832
&object_or_type_eval[0].symbol.get_symbol(
833833
session, context, &mut diagnostics, Some(parent.clone())),
834-
session, &mut None, false, false, None, &mut diagnostics)[0];
834+
session, &mut None, false, false, None)[0];
835835
if object_or_type_weak_eval.is_weak() {
836836
is_instance = Some(object_or_type_weak_eval.as_weak().instance.unwrap_or(default_instance));
837837
} else {
@@ -1022,7 +1022,7 @@ impl Evaluation {
10221022
if base_ref.is_expired_if_weak() {
10231023
return AnalyzeAstResult::from_only_diagnostics(diagnostics);
10241024
}
1025-
let bases = Symbol::follow_ref(&base_ref, session, context, false, false, None, &mut diagnostics);
1025+
let bases = Symbol::follow_ref(&base_ref, session, context, false, false, None);
10261026
for ibase in bases.iter() {
10271027
let base_loc = ibase.upgrade_weak();
10281028
if let Some(base_loc) = base_loc {
@@ -1144,7 +1144,7 @@ impl Evaluation {
11441144
if base.is_expired_if_weak() {
11451145
return AnalyzeAstResult::from_only_diagnostics(diagnostics);
11461146
}
1147-
let bases = Symbol::follow_ref(&base, session, &mut None, false, false, None, &mut diagnostics);
1147+
let bases = Symbol::follow_ref(&base, session, &mut None, false, false, None);
11481148
if bases.len() != 1 {
11491149
return AnalyzeAstResult::from_only_diagnostics(diagnostics);
11501150
}
@@ -1261,7 +1261,7 @@ impl Evaluation {
12611261
diagnostics.extend(diags);
12621262
for base in bases.into_iter(){
12631263
let base_sym_weak_eval= base.symbol.get_symbol_weak_transformed(session, context, &mut diagnostics, None);
1264-
let base_eval_ptrs = Symbol::follow_ref(&base_sym_weak_eval, session, context, true, false, None, &mut diagnostics);
1264+
let base_eval_ptrs = Symbol::follow_ref(&base_sym_weak_eval, session, context, true, false, None);
12651265
for base_eval_ptr in base_eval_ptrs.iter() {
12661266
let EvaluationSymbolPtr::WEAK(base_sym_weak_eval) = base_eval_ptr else {continue};
12671267
let Some(base_sym) = base_sym_weak_eval.weak.upgrade() else {continue};
@@ -1531,7 +1531,7 @@ impl Evaluation {
15311531
diagnostics
15321532
}
15331533

1534-
fn validate_tuple_search_domain(session: &mut SessionInfo, on_object: Weak<RefCell<Symbol>>, from_module: Option<Rc<RefCell<Symbol>>>, elt1: &Expr, elt2: &Expr, elt3: &Expr, diagnostics: &mut Vec<Diagnostic>) {
1534+
fn validate_tuple_search_domain(session: &mut SessionInfo, on_object: Weak<RefCell<Symbol>>, from_module: Option<Rc<RefCell<Symbol>>>, elt1: &Expr, elt2: &Expr, _elt3: &Expr, diagnostics: &mut Vec<Diagnostic>) {
15351535
//parameter 1
15361536
if let Some(on_object) = on_object.upgrade() { //if weak is not set, we didn't manage to evalue base object. Do not validate in this case
15371537
match elt1 {
@@ -1763,7 +1763,7 @@ impl EvaluationSymbolPtr {
17631763

17641764
pub(crate) fn is_weak(&self) -> bool {
17651765
match self {
1766-
EvaluationSymbolPtr::WEAK(w) => true,
1766+
EvaluationSymbolPtr::WEAK(_) => true,
17671767
_ => false
17681768
}
17691769
}

server/src/core/file_mgr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use lsp_types::notification::{Notification, PublishDiagnostics};
22
use ropey::Rope;
3-
use ruff_python_ast::{AnyRootNodeRef, Mod, ModModule, PySourceType, Stmt};
4-
use ruff_python_parser::{Mode, ParseOptions, Parsed, Token, TokenKind};
3+
use ruff_python_ast::{ModModule, PySourceType, Stmt};
4+
use ruff_python_parser::{Parsed, Token, TokenKind};
55
use lsp_types::{Diagnostic, DiagnosticSeverity, MessageType, NumberOrString, Position, PublishDiagnosticsParams, Range, TextDocumentContentChangeEvent};
66
use tracing::{error, warn};
77
use std::collections::hash_map::DefaultHasher;

server/src/core/model.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use crate::constants::BuildSteps;
1212
use crate::constants::OYarn;
1313
use crate::constants::SymType;
1414
use crate::threads::SessionInfo;
15-
use crate::Sy;
1615

1716
use super::symbols::module_symbol::ModuleSymbol;
1817
use super::symbols::symbol::Symbol;

server/src/core/odoo.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::core::diagnostics::{create_diagnostic, DiagnosticCode};
22
use crate::core::entry_point::EntryPointType;
33
use crate::core::file_mgr::AstType;
4-
use crate::core::symbols::file_symbol;
54
use crate::core::xml_data::OdooData;
65
use crate::core::xml_validation::XmlValidator;
76
use crate::features::document_symbols::DocumentSymbolFeature;
@@ -20,7 +19,6 @@ use std::time::Instant;
2019
use lsp_server::ResponseError;
2120
use lsp_types::*;
2221
use request::{RegisterCapability, Request, WorkspaceConfiguration};
23-
use ruff_python_parser::{Mode, ParseOptions};
2422
use serde_json::Value;
2523
use tracing::{error, warn, info, trace};
2624

@@ -1321,7 +1319,7 @@ impl Odoo {
13211319
Ok(None)
13221320
}
13231321

1324-
pub fn handle_did_change_configuration(session: &mut SessionInfo, _params: DidChangeConfigurationParams) {
1322+
pub fn handle_did_change_configuration(_session: &mut SessionInfo, _params: DidChangeConfigurationParams) {
13251323
return;
13261324
}
13271325

@@ -1593,7 +1591,7 @@ impl Odoo {
15931591
(false, false)
15941592
}
15951593

1596-
pub fn update_file_index(session: &mut SessionInfo, path: PathBuf, is_save: bool, is_open: bool, force_delay: bool) {
1594+
pub fn update_file_index(session: &mut SessionInfo, path: PathBuf, is_save: bool, _is_open: bool, force_delay: bool) {
15971595
if matches!(path.extension().and_then(OsStr::to_str), Some(ext) if ["py", "xml", "csv"].contains(&ext)) || Odoo::is_config_workspace_file(session, &path){
15981596
SessionInfo::request_update_file_index(session, &path, is_save, force_delay);
15991597
}

0 commit comments

Comments
 (0)