Skip to content

Commit

Permalink
style: fix code style and redundant conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick-Remy committed Sep 15, 2023
1 parent 52f3a27 commit 63812ac
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,9 @@ public static function taintUnspecializedProperty(
if ($statements_analyzer->data_flow_graph instanceof TaintFlowGraph) {
$taint_source = TaintSource::fromNode($property_node);
$statements_analyzer->data_flow_graph->addSource($taint_source);
$assignment_value_type = $assignment_value_type->addParentNodes([$taint_source->id => $taint_source]);
$assignment_value_type = $assignment_value_type->addParentNodes([

Check failure on line 631 in src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php

View workflow job for this annotation

GitHub Actions / build

UnusedVariable

src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php:631:13: UnusedVariable: $assignment_value_type is never referenced or the value is not used (see https://psalm.dev/077)
$taint_source->id => $taint_source
]);
}

$declaring_property_class = $codebase->properties->getDeclaringClassForProperty(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -873,11 +873,9 @@ private static function getAnalyzeNamedExpression(
);
}

if ($statements_analyzer->data_flow_graph instanceof TaintFlowGraph) {
$taint_source = TaintSource::fromNode($custom_call_sink);
$statements_analyzer->data_flow_graph->addSource($taint_source);
$stmt_name_type = $stmt_name_type->addParentNodes([$taint_source->id => $taint_source]);
}
$taint_source = TaintSource::fromNode($custom_call_sink);
$statements_analyzer->data_flow_graph->addSource($taint_source);
$stmt_name_type = $stmt_name_type->addParentNodes([$taint_source->id => $taint_source]);

Check failure on line 878 in src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php

View workflow job for this annotation

GitHub Actions / build

UnusedVariable

src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php:878:17: UnusedVariable: $stmt_name_type is never referenced or the value is not used (see https://psalm.dev/077)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,11 +688,9 @@ private static function analyzeConstructorExpression(
);
}

if ($statements_analyzer->data_flow_graph instanceof TaintFlowGraph) {
$taint_source = TaintSource::fromNode($custom_call_sink);
$statements_analyzer->data_flow_graph->addSource($taint_source);
$stmt_class_type = $stmt_class_type->addParentNodes([$taint_source->id => $taint_source]);
}
$taint_source = TaintSource::fromNode($custom_call_sink);
$statements_analyzer->data_flow_graph->addSource($taint_source);
$stmt_class_type = $stmt_class_type->addParentNodes([$taint_source->id => $taint_source]);
}

if (self::checkMethodArgs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ public static function analyze(
);
}

if ($statements_analyzer->data_flow_graph instanceof TaintFlowGraph) {
$taint_source = TaintSource::fromNode($eval_param_sink);
$statements_analyzer->data_flow_graph->addSource($taint_source);
$expr_type = $expr_type->addParentNodes([$taint_source->id => $taint_source]);
}
$taint_source = TaintSource::fromNode($eval_param_sink);
$statements_analyzer->data_flow_graph->addSource($taint_source);
$expr_type = $expr_type->addParentNodes([$taint_source->id => $taint_source]);

Check failure on line 76 in src/Psalm/Internal/Analyzer/Statements/Expression/EvalAnalyzer.php

View workflow job for this annotation

GitHub Actions / build

UnusedVariable

src/Psalm/Internal/Analyzer/Statements/Expression/EvalAnalyzer.php:76:17: UnusedVariable: $expr_type is never referenced or the value is not used (see https://psalm.dev/077)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,9 @@ public static function analyze(
);
}

if ($statements_analyzer->data_flow_graph instanceof TaintFlowGraph) {
$taint_source = TaintSource::fromNode($include_param_sink);
$statements_analyzer->data_flow_graph->addSource($taint_source);
$stmt_expr_type = $stmt_expr_type->addParentNodes([$taint_source->id => $taint_source]);
}
$taint_source = TaintSource::fromNode($include_param_sink);
$statements_analyzer->data_flow_graph->addSource($taint_source);
$stmt_expr_type = $stmt_expr_type->addParentNodes([$taint_source->id => $taint_source]);

Check failure on line 153 in src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php

View workflow job for this annotation

GitHub Actions / build

UnusedVariable

src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php:153:13: UnusedVariable: $stmt_expr_type is never referenced or the value is not used (see https://psalm.dev/077)
}

if ($path_to_file) {
Expand Down
5 changes: 3 additions & 2 deletions src/Psalm/Internal/DataFlow/TaintSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
*/
class TaintSource extends DataFlowNode
{
public static function fromNode(DataFlowNode $node): self {
public static function fromNode(DataFlowNode $node): self
{
return new self(
$node->id,
$node->label,
$node->code_location,
$node->specialization_key,
$node->taints
$node->taints,
);
}
}

0 comments on commit 63812ac

Please sign in to comment.