Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self):
copy_item_value_and_insert_new_item_after_item_rule.__init__(self, 'context', '022', parser.context_end_context_keyword, parser.context_semicolon, parser.context_identifier, parser.context_end_identifier('unknown'))
self.solution = 'missing context identifier'
self.subphase = 2
def __init__(self):
insert_blank_line_above_line_containing_item_rule.__init__(self, 'context', '003', parser.context_keyword, True)
def __init__(self):
case_item_rule.__init__(self, 'context', '012', parser.context_identifier)
def classify_context_end_context_keyword(sToken, iToken, lObjects):
if sToken.lower() == 'context':
lObjects[iToken] = parser.context_end_context_keyword(sToken)
def classify_context_end_identifier(sToken, iToken, lObjects):
if sToken.lower() != 'context' and sToken != ';' and not isinstance(lObjects[iToken], parser.whitespace) and not isinstance(lObjects[iToken], parser.comment):
lObjects[iToken] = parser.context_end_identifier(sToken)
def analyze(self, oFile):
self._print_debug_message('Analyzing rule: ' + self.name + '_' + self.identifier)
lContexts = oFile.get_context_declarations()
for dContext in lContexts:
for iLine, oLine in enumerate(dContext['lines']):
lObjects = oLine.get_objects()
lAnalysis = []
bLeftFound = False
for iObject, oObject in enumerate(lObjects):
if isinstance(oObject, self.left):
bLeftFound = True
if bLeftFound:
lAnalysis.append(oObject)
if isinstance(oObject, self.right):
if len(lAnalysis) == 3:
if isinstance(lAnalysis[1], parser.whitespace):
if lAnalysis[1].get_value() != ' ' * self.spaces:
dViolation = utils.create_violation_dict(dContext['metadata']['iStartLineNumber'] + iLine)
dViolation['solution'] = 'Ensure there are only ' + str(self.spaces) + ' space(s) between "' + lAnalysis[0].get_value() + '" and "' + lAnalysis[2].get_value() + '"'
self.add_violation(dViolation)
def __init__(self):
insert_item_after_item_rule.__init__(self, 'context', '021', parser.context_end_keyword, parser.context_semicolon, parser.context_end_context_keyword('context'))
self.insert_space = True
def classify_context_end_keyword(sToken, iToken, lObjects, dVars):
if sToken.lower() == 'end':
lObjects[iToken] = parser.context_end_keyword(sToken)
dVars['bContextEndFound'] = True