Skip to content

Commit

Permalink
Formatting my code sucht that it will pass the perl check
Browse files Browse the repository at this point in the history
  • Loading branch information
Mal-One committed Mar 15, 2024
1 parent 25bc001 commit 747b702
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 33 deletions.
42 changes: 25 additions & 17 deletions lib/ProductOpener/DataQualityFood.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1303,24 +1303,32 @@ sub check_nutrition_data ($product_ref) {
}


# sum of nutriments that compose fiber can not be greater than fiber value
if ((defined $product_ref->{nutriments}{fiber_100g})
and (
(
(
(defined $product_ref->{nutriments}{'soluble-fiber_100g'}) ? $product_ref->{nutriments}{'soluble-fiber_100g'}
: 0
) + (
(defined $product_ref->{nutriments}{'insoluble-fiber_100g'}) ? $product_ref->{nutriments}{'insoluble-fiber_100g'}
: 0
# sum of nutriments that compose fiber can not be greater than fiber value
if (
( defined $product_ref->{nutriments}{fiber_100g} )
and (
(
(
(
defined $product_ref->{nutriments}
{'soluble-fiber_100g'}
) ? $product_ref->{nutriments}{'soluble-fiber_100g'}
: 0
) + (
(
defined $product_ref->{nutriments}
{'insoluble-fiber_100g'}
) ? $product_ref->{nutriments}{'insoluble-fiber_100g'}
: 0
)
) > ( $product_ref->{nutriments}{fiber_100g} ) + 0.001
)
) > ($product_ref->{nutriments}{fiber_100g}) + 0.001
)
)
{
push @{$product_ref->{data_quality_errors_tags}},
"en:nutrition-soluble-fiber-plus-insoluble-fiber-greater-than-fiber";
}
)
{
push @{ $product_ref->{data_quality_errors_tags} },
"en:nutrition-soluble-fiber-plus-insoluble-fiber-greater-than-fiber";
}


# Too small salt value? (e.g. g entered in mg)
# warning for salt < 0.1 was removed because it was leading to too much false positives (see #9346)
Expand Down
32 changes: 16 additions & 16 deletions tests/unit/dataqualityfood.t
Original file line number Diff line number Diff line change
Expand Up @@ -1871,21 +1871,21 @@ ok(
# Test case for fiber content
$product_ref = {
nutriments => {
fiber_100g => 5,
'soluble-fiber_100g' => 3,
'insoluble-fiber_100g' => 3,
},
data_quality_errors_tags => [],
};

ProductOpener::DataQuality::check_quality($product_ref);

ok(
has_tag(
$product_ref, 'data_quality_errors',
'en:nutrition-soluble-fiber-plus-insoluble-fiber-greater-than-fiber'
),
'Soluble fiber + Insoluble fiber exceeds total fiber'
) or diag explain $product_ref;
fiber_100g => 5,
'soluble-fiber_100g' => 3,
'insoluble-fiber_100g' => 3,
},
data_quality_errors_tags => [],
};

ProductOpener::DataQuality::check_quality($product_ref);

ok(
has_tag(
$product_ref, 'data_quality_errors',
'en:nutrition-soluble-fiber-plus-insoluble-fiber-greater-than-fiber'
),
'Soluble fiber + Insoluble fiber exceeds total fiber'
) or diag explain $product_ref;

done_testing();

0 comments on commit 747b702

Please sign in to comment.