Skip to content

Commit

Permalink
Fix more clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Feb 9, 2024
1 parent 7c5bf6c commit 4080540
Show file tree
Hide file tree
Showing 32 changed files with 1,359 additions and 1,466 deletions.
2 changes: 1 addition & 1 deletion src/analyzer/expr/binop/and_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
use std::rc::Rc;

use crate::function_analysis_data::FunctionAnalysisData;
use crate::reconciler::reconciler;
use crate::reconciler;
use crate::scope_context::ScopeContext;
use crate::statements_analyzer::StatementsAnalyzer;
use crate::stmt::if_conditional_analyzer::handle_paradoxical_condition;
Expand Down
12 changes: 1 addition & 11 deletions src/analyzer/expr/binop/assignment_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,7 @@ pub(crate) fn analyze(
analysis_data,
);
} else {
let root_var_id = get_root_var_id(
assign_var,
context.function_context.calling_class.as_ref(),
Some(statements_analyzer.get_file_analyzer().get_file_source()),
);
let root_var_id = get_root_var_id(assign_var);

if let Some(root_var_id) = root_var_id {
if let Some(existing_root_type) = context.vars_in_scope.get(&root_var_id).cloned() {
Expand All @@ -288,12 +284,6 @@ pub(crate) fn analyze(
}
}

if assign_value_type.is_mixed() {
// we don't really need to know about MixedAssignment, but in Psalm we trigger an issue here
} else {
// todo increment non-mixed count
}

analysis_data.expr_effects.insert(
(pos.start_offset() as u32, pos.end_offset() as u32),
EFFECT_WRITE_LOCAL,
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/expr/binop/or_analyzer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rustc_hash::{FxHashMap, FxHashSet};
use std::rc::Rc;

use crate::reconciler::reconciler;
use crate::reconciler;
use crate::scope_analyzer::ScopeAnalyzer;
use crate::scope_context::ScopeContext;
use crate::statements_analyzer::StatementsAnalyzer;
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/expr/call/function_call_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::expr::call::arguments_analyzer;
use crate::expr::call_analyzer::{apply_effects, check_template_result};
use crate::expr::{echo_analyzer, exit_analyzer, expression_identifier, isset_analyzer};
use crate::function_analysis_data::FunctionAnalysisData;
use crate::reconciler::reconciler;
use crate::reconciler;
use crate::scope_analyzer::ScopeAnalyzer;
use crate::scope_context::ScopeContext;
use crate::statements_analyzer::StatementsAnalyzer;
Expand Down
11 changes: 3 additions & 8 deletions src/analyzer/expr/expression_identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use hakana_reflection_info::{
};
use rustc_hash::{FxHashMap, FxHashSet};

use hakana_reflection_info::FileSource;
use oxidized::{aast, ast_defs};

// gets a var id from a simple variable
Expand Down Expand Up @@ -97,15 +96,11 @@ pub fn get_var_id(
}

// gets a the beginning var id from a chain
pub(crate) fn get_root_var_id(
conditional: &aast::Expr<(), ()>,
this_class_name: Option<&StrId>,
source: Option<&FileSource>,
) -> Option<String> {
pub(crate) fn get_root_var_id(conditional: &aast::Expr<(), ()>) -> Option<String> {
match &conditional.2 {
aast::Expr_::Lvar(var_expr) => Some(var_expr.1 .1.clone()),
aast::Expr_::ArrayGet(boxed) => get_root_var_id(&boxed.0, this_class_name, source),
aast::Expr_::ObjGet(boxed) => get_root_var_id(&boxed.0, this_class_name, source),
aast::Expr_::ArrayGet(boxed) => get_root_var_id(&boxed.0),
aast::Expr_::ObjGet(boxed) => get_root_var_id(&boxed.0),
_ => None,
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/analyzer/expr/ternary_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::BTreeMap;
use std::rc::Rc;

use crate::function_analysis_data::FunctionAnalysisData;
use crate::reconciler::{assertion_reconciler, reconciler};
use crate::reconciler::{self, assertion_reconciler};
use crate::scope_analyzer::ScopeAnalyzer;
use crate::scope_context::if_scope::IfScope;
use crate::scope_context::{var_has_root, ScopeContext};
Expand Down Expand Up @@ -92,9 +92,7 @@ pub(crate) fn analyze(
if_clauses = if_clauses
.into_iter()
.map(|c| {
let keys = &c
.possibilities.keys()
.collect::<Vec<&String>>();
let keys = &c.possibilities.keys().collect::<Vec<&String>>();

let mut new_mixed_var_ids = vec![];
for i in mixed_var_ids.clone() {
Expand Down Expand Up @@ -340,10 +338,12 @@ pub(crate) fn analyze(
let mut removed_vars = FxHashSet::default();

let redef_var_ifs = if_context
.get_redefined_vars(&context.vars_in_scope, false, &mut removed_vars).into_keys()
.get_redefined_vars(&context.vars_in_scope, false, &mut removed_vars)
.into_keys()
.collect::<FxHashSet<_>>();
let redef_var_else = temp_else_context
.get_redefined_vars(&context.vars_in_scope, false, &mut removed_vars).into_keys()
.get_redefined_vars(&context.vars_in_scope, false, &mut removed_vars)
.into_keys()
.collect::<FxHashSet<_>>();

let redef_all = redef_var_ifs
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/expression_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::expr::{
unop_analyzer, variable_fetch_analyzer, xml_analyzer, yield_analyzer,
};
use crate::function_analysis_data::FunctionAnalysisData;
use crate::reconciler::reconciler;
use crate::reconciler;
use crate::scope_analyzer::ScopeAnalyzer;
use crate::scope_context::{var_has_root, ScopeContext};
use crate::statements_analyzer::StatementsAnalyzer;
Expand Down
3 changes: 1 addition & 2 deletions src/analyzer/reconciler/assertion_reconciler.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::{collections::BTreeMap, sync::Arc};

use super::{
negated_assertion_reconciler, reconciler::trigger_issue_for_impossible,
simple_assertion_reconciler,
negated_assertion_reconciler, simple_assertion_reconciler, trigger_issue_for_impossible,
};
use crate::{
function_analysis_data::FunctionAnalysisData, scope_analyzer::ScopeAnalyzer,
Expand Down
Loading

0 comments on commit 4080540

Please sign in to comment.