def test_read_json_file(self): """ Test whether read_json_file correctly reads a file of Perceval data, where each line in the file is of json format. """ expected = read_file('data/test_commits_data.json') items = read_json_file('data/test_commits_data.json') self.assertEqual(expected, items)
lines modified (int) """ modifications_count = 0 for item in self.items: modifications_count += item['modifications'] return modifications_count def __str__(self): return "Code Changes Lines" if __name__ == "__main__": date_since = datetime.strptime("2018-09-07", "%Y-%m-%d") items = read_json_file('../git-commits.json') # total number of line changes changes = CodeChangesLinesGit(items, date_range=(None, None)) print("Code_Changes_Lines, total changes:", changes.compute()) # number of line changes after imposing conditions changes = CodeChangesLinesGit( items, date_range=(None, None), is_code=[DirExclude(['tests']), PostfixExclude(['.md', 'COPYING'])]) print("Code_Changes_Lines, excluding some files:", changes.compute()) # total line changes after a certain date changes = CodeChangesLinesGit(items,
class ReviewsGitHub(PullRequestGitHub): """ Class for the Reviews metric (non-pandas) """ def compute(self): """ Compute the total number of reviews created, from the Perceval data. :returns: The total number of reviews created """ pull_ids = {item['hash'] for item in self.items} return len(pull_ids) def __str__(self): return "Reviews" if __name__ == "__main__": date_since = datetime.strptime("2018-09-07", "%Y-%m-%d") items = read_json_file('../pull_requests.json') # total number of reviews reviews = ReviewsGitHub(items) print("The total number of reviews is {}".format(reviews.compute())) # reviews created after a certain date reviews = ReviewsGitHub(items, (date_since, None)) print("The number of reviews created after 2018-09-07 is {}".format( reviews.compute()))