def test_fix_rule_005(self): oRule = sequential.rule_005() oRule.fix(self.oFile) lActual = self.oFile.get_lines() self.assertEqual(lExpected_all, lActual) oRule.analyze(self.oFile) self.assertEqual(oRule.violations, [])
def test_rule_005(self): oRule = sequential.rule_005() self.assertTrue(oRule) self.assertEqual(oRule.name, 'sequential') self.assertEqual(oRule.identifier, '005') dExpected = [ '13-15', '20-22', '26-28', '38-40', '53-58', '65-66', '73-75', '80-81', '88-90' ] oRule.analyze(oFile) self.assertEqual(oRule.violations, dExpected)
def test_rule_005(self): oRule = sequential.rule_005() self.assertTrue(oRule) self.assertEqual(oRule.name, 'sequential') self.assertEqual(oRule.identifier, '005') lExpected = [48, 49, 50, 53, 54, 55, 57, 58, 66, 67, 68] oRule.analyze(self.oFile) self.assertEqual( lExpected, utils.extract_violation_lines_from_violation_object( oRule.violations))
def test_fix_rule_005_allowing_blank_and_no_loop(self): oRule = sequential.rule_005() oRule.blank_line_ends_group = False oRule.loop_control_statements_ends_group = True oRule.fix(self.oFile) lActual = self.oFile.get_lines() self.assertEqual(lExpected_blank_no_loop, lActual) oRule.analyze(self.oFile) self.assertEqual(oRule.violations, [])
def test_fix_rule_005_allowing_blank_and_when(self): oRule = sequential.rule_005() oRule.case_control_statements_ends_group = 'break_on_case_or_end_case' oRule.blank_line_ends_group = False oRule.fix(self.oFile) lActual = self.oFile.get_lines() self.assertEqual(lExpected_blank_when, lActual) oRule.analyze(self.oFile) self.assertEqual(oRule.violations, [])
def test_rule_005_allowing_blank_no_loop(self): oRule = sequential.rule_005() self.assertTrue(oRule) self.assertEqual(oRule.name, 'sequential') self.assertEqual(oRule.identifier, '005') oRule.blank_line_ends_group = False oRule.loop_control_statements_ends_group = True lExpected = [48, 49, 50, 53, 54, 55, 57, 58, 66, 67, 68] oRule.analyze(self.oFile) self.assertEqual( lExpected, utils.extract_violation_lines_from_violation_object( oRule.violations))
def test_rule_005_allowing_blank_and_case(self): oRule = sequential.rule_005() self.assertTrue(oRule) self.assertEqual(oRule.name, 'sequential') self.assertEqual(oRule.identifier, '005') oRule.case_control_statements_ends_group = False oRule.blank_line_ends_group = False lExpected = [ 31, 32, 33, 35, 36, 37, 48, 49, 50, 53, 54, 55, 57, 58, 66, 67, 68, 72, 73, 74, 77, 78, 79, 89, 90, 91 ] oRule.analyze(self.oFile) self.assertEqual( lExpected, utils.extract_violation_lines_from_violation_object( oRule.violations))
def test_rule_005(self): oRule = sequential.rule_005() self.assertTrue(oRule) self.assertEqual(oRule.name, 'sequential') self.assertEqual(oRule.identifier, '005') dExpected = [{ 'lines': [{ 'number': 13, 'keyword_column': 6, 'before_keyword_column': 4 }, { 'number': 14, 'keyword_column': 4, 'before_keyword_column': 2 }, { 'number': 15, 'keyword_column': 6, 'before_keyword_column': 4 }], 'max_keyword_column': 6, 'max_before_keyword_column': 4 }, { 'lines': [{ 'number': 20, 'keyword_column': 11, 'before_keyword_column': 9 }, { 'number': 21, 'keyword_column': 10, 'before_keyword_column': 8 }, { 'number': 22, 'keyword_column': 10, 'before_keyword_column': 8 }], 'max_keyword_column': 11, 'max_before_keyword_column': 9 }, { 'lines': [{ 'number': 26, 'keyword_column': 10, 'before_keyword_column': 8 }, { 'number': 27, 'keyword_column': 10, 'before_keyword_column': 8 }, { 'number': 28, 'keyword_column': 8, 'before_keyword_column': 6 }], 'max_keyword_column': 10, 'max_before_keyword_column': 8 }, { 'lines': [{ 'number': 38, 'keyword_column': 9, 'before_keyword_column': 8 }, { 'number': 39, 'keyword_column': 10, 'before_keyword_column': 8 }, { 'number': 40, 'keyword_column': 9, 'before_keyword_column': 8 }], 'max_keyword_column': 10, 'max_before_keyword_column': 8 }, { 'lines': [{ 'number': 53, 'keyword_column': 8, 'before_keyword_column': 4 }, { 'number': 56, 'keyword_column': 7, 'before_keyword_column': 4 }, { 'number': 57, 'keyword_column': 8, 'before_keyword_column': 6 }], 'max_keyword_column': 8, 'max_before_keyword_column': 6 }, { 'lines': [{ 'number': 65, 'keyword_column': 12, 'before_keyword_column': 10 }, { 'number': 66, 'keyword_column': 13, 'before_keyword_column': 11 }], 'max_keyword_column': 13, 'max_before_keyword_column': 11 }, { 'lines': [{ 'number': 73, 'keyword_column': 15, 'before_keyword_column': 13 }, { 'number': 75, 'keyword_column': 14, 'before_keyword_column': 11 }], 'max_keyword_column': 15, 'max_before_keyword_column': 13 }, { 'lines': [{ 'number': 80, 'keyword_column': 10, 'before_keyword_column': 8 }, { 'number': 81, 'keyword_column': 8, 'before_keyword_column': 7 }], 'max_keyword_column': 10, 'max_before_keyword_column': 8 }, { 'lines': [{ 'number': 88, 'keyword_column': 10, 'before_keyword_column': 8 }, { 'number': 89, 'keyword_column': 8, 'before_keyword_column': 7 }, { 'number': 90, 'keyword_column': 11, 'before_keyword_column': 9 }], 'max_keyword_column': 11, 'max_before_keyword_column': 9 }] oRule.analyze(oFile) self.assertEqual(oRule.violations, dExpected)
def test_fix_rule_005(self): oRule = sequential.rule_005() dExpected = [] oRule.fix(oFile) oRule.analyze(oFile) self.assertEqual(oRule.violations, dExpected)