Beispiel #1
0
 def test_unrelated_command(self):
     results = []
     doc = self.g4
     smells_to_check = [Smell.unrelated_commands.value]
     if doc:
         results = search_for_smells(doc, self.project_name, False, smells_to_check)
     self.assertEqual(results.pop(), Smell.unrelated_commands.value)
Beispiel #2
0
 def test_bypassing_security_check(self):
     results = []
     doc = self.g2
     smells_to_check = [Smell.bypassing_security_checks.value]
     if doc:
         results = search_for_smells(doc, self.project_name, False, smells_to_check)
     self.assertEqual(results.pop(), Smell.bypassing_security_checks.value)
Beispiel #3
0
 def test_irrelevant_properties(self):
     results = []
     doc = self.g3
     smells_to_check = [Smell.irrelevant_properties.value]
     if doc:
         results = search_for_smells(doc, self.project_name, False, smells_to_check)
     self.assertEqual(results.pop(), Smell.irrelevant_properties.value)
Beispiel #4
0
 def test_detection_curling_to_interpreter(self):
     results = []
     doc = self.g1
     smells_to_check = [Smell.curling_to_interpreter.value]
     if doc:
         results = search_for_smells(doc, self.project_name, False, smells_to_check)
     self.assertEqual(results.pop(), Smell.curling_to_interpreter.value)
Beispiel #5
0
    if args.verbose:
        verbose = True
    if args.smells:
        smells_to_check = args.smells
    yaml_path_new = args.new_path
    yaml_path = args.path

    print('Checked Anti-patterns:')
    for i in smells_to_check:
        print('+ ' + str(Smell(i)))

    with codecs.open(yaml_path, 'r', 'utf-8') as f:
        try:
            doc = yaml.load(f)
            if doc:
                results = search_for_smells(doc, yaml_path, node_only,
                                            smells_to_check)
                print('-----------------------------------')
                print('Summary:')
                print('-----------------------------------')
                print(len(results), 'Anti-pattern(s) detected.')
                for i in results:
                    print('+ ' + str(Smell(i)))
                print('-----------------------------------')

        except yaml.scanner.ScannerError as err:
            print("Scanner Error...", yaml_path)
            print(err)
        except yaml.composer.ComposerError as err:
            print("Composer Error...", yaml_path)
            print(err)
        except yaml.parser.ParserError: