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_is_cache(self): self.assertEqual(is_cached(self.repo), False) cache(self.repo) self.assertEqual(is_cached(self.repo), True)