def report(repo_url): repo = create_repository(repo_url) if repo is None: flash('Given repository does not exists or could not be accessed') return redirect(url_for('index')) if is_cached(repo): results = mongo.db.repositories.find_one({'url': repo.url}) else: path = clone(repo) results = analyze(path) repo.save_analysis_results(results) cache(repo) clear(path) results = repo.to_document() return render_template('report/results.html', report=results)
def report(repo_url): repo = create_repository(repo_url) if repo is None: flash('Given repository does not exists or could not be accessed') return redirect(url_for('index')) if is_cached(repo): results = mongo.db.repositories.find_one({'url': repo.url}) else: path = clone(repo) count_analyzer = CountAnalyzer() pep8_analyzer = PEP8LintAnalyzer() pyflakes_analyzer = PyflakesLintAnalyzer() license_analyzer = LicenseAnalyzer() count_analyzer.run(path) pep8_analyzer.run(path) pyflakes_analyzer.run(path) license_analyzer.run(path) pep8_analyzer.calculate_score(count_analyzer.total_line_count) pyflakes_analyzer.calculate_score(count_analyzer.total_line_count) repo.save_analysis_results({ **count_analyzer.to_document(), **pep8_analyzer.to_document(), **pyflakes_analyzer.to_document(), **license_analyzer.to_document(), 'report_grade': calculate_report_grade(pep8_analyzer, pyflakes_analyzer) }) cache(repo) clear(path) results = repo.to_document() return render_template('report/results.html', report=results)
def test_clone_fail(self): self.repo.url = 'github.com/mingrammer/null' with self.assertRaises(Exception): clone(self.repo.url)
def test_clone(self): cloned_path = clone(self.repo) self.assertEqual(cloned_path, os.path.join(Config.CLONE_TMP_DIR, self.repo.name))