Skip to content

Commit 4a5f0a2

Browse files
committed
Solve Code Climate problem
Reduce code complexity by extracting the code to a static method.
1 parent 8e7284c commit 4a5f0a2

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

ssg/build_yaml.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -741,16 +741,22 @@ def __deepcopy__(self, memo):
741741
return result
742742

743743
@staticmethod
744-
def _convert_platform_names(env_yaml, rule, product_cpes):
744+
def _has_platforms_to_convert(env_yaml, rule, product_cpes):
745745
# Convert the platform names to CPE names
746746
# But only do it if an env_yaml was specified (otherwise there would
747747
# be no product CPEs to lookup), and the rule's prodtype matches the
748748
# product being built also if the rule already has cpe_platform_names
749749
# specified (compiled rule) do not evaluate platforms again
750-
if (not env_yaml or
751-
(env_yaml["product"] not in parse_prodtype(rule.prodtype)
752-
and rule.prodtype != "all") or
753-
(not product_cpes or rule.cpe_platform_names)):
750+
return (
751+
env_yaml and
752+
(env_yaml["product"] in parse_prodtype(rule.prodtype) or
753+
rule.prodtype == "all") and
754+
(product_cpes and not rule.cpe_platform_names)
755+
)
756+
757+
@staticmethod
758+
def _convert_platform_names(env_yaml, rule, product_cpes):
759+
if not Rule._has_platforms_to_convert(env_yaml, rule, product_cpes):
754760
return
755761
# parse platform definition and get CPEAL platform
756762
for platform in rule.platforms:

0 commit comments

Comments
 (0)