ComplianceAsCode/content

View on GitHub
shared/templates/file_groupowner/template.py

Summary

Maintainability
D
1 day
Test Coverage
Similar blocks of code found in 2 locations. Consider refactoring.
from ssg.utils import parse_template_boolean_value
Similar blocks of code found in 2 locations. Consider refactoring.
from ssg.utils import ensure_file_paths_and_file_regexes_are_correctly_defined
Similar blocks of code found in 2 locations. Consider refactoring.
 
Similar blocks of code found in 2 locations. Consider refactoring.
 
Similar blocks of code found in 2 locations. Consider refactoring.
def preprocess(data, lang):
Similar blocks of code found in 2 locations. Consider refactoring.
ensure_file_paths_and_file_regexes_are_correctly_defined(data)
Similar blocks of code found in 2 locations. Consider refactoring.
 
Similar blocks of code found in 2 locations. Consider refactoring.
data["recursive"] = parse_template_boolean_value(data,
Similar blocks of code found in 2 locations. Consider refactoring.
parameter="recursive",
Similar blocks of code found in 2 locations. Consider refactoring.
default_value=False)
Similar blocks of code found in 2 locations. Consider refactoring.
 
Similar blocks of code found in 2 locations. Consider refactoring.
try:
Similar blocks of code found in 2 locations. Consider refactoring.
int(data["gid_or_name"])
Similar blocks of code found in 2 locations. Consider refactoring.
data["group_represented_with_gid"] = True
Similar blocks of code found in 2 locations. Consider refactoring.
except ValueError:
Similar blocks of code found in 2 locations. Consider refactoring.
data["group_represented_with_gid"] = False
Similar blocks of code found in 2 locations. Consider refactoring.
 
Similar blocks of code found in 2 locations. Consider refactoring.
if data["group_represented_with_gid"] == False:
Similar blocks of code found in 2 locations. Consider refactoring.
groups = data["gid_or_name"].split("|")
Similar blocks of code found in 2 locations. Consider refactoring.
if any(element.isnumeric() for element in groups):
Similar blocks of code found in 2 locations. Consider refactoring.
raise ValueError("gid_or_name list cannot contain gids when there are multiple groups")
Similar blocks of code found in 2 locations. Consider refactoring.
 
Similar blocks of code found in 2 locations. Consider refactoring.
if lang == "oval":
Similar blocks of code found in 2 locations. Consider refactoring.
data["fileid"] = data["_rule_id"].replace("file_groupowner", "")
Similar blocks of code found in 2 locations. Consider refactoring.
return data