Beispiel #1
0
def run(repo, doc, end_date):
    doc['collaborators'] = collaborators(repo)

    url = 'https://api.github.com/repos/{user}/{repo_name}'.format(
        user=repo.user,
        repo_name=repo.repo_name
    )
    response = requests.get(url)
    data = json.loads(response.text)

    result = {k: data[k] for k in ('watchers', 'forks', 'open_issues')}
    result['num_collaborators'] = len(doc['collaborators'])
    doc['popularity'].append(weekly_data(end_date, result))
Beispiel #2
0
def run(repo, doc, on_date):
    counts = defaultdict(int)

    for word in SWEAR_WORDS:
        cmd = ['grep', word, '-rw', repo.working_dir]

        try:
            output = subprocess.check_output(cmd)
            # results += output.split("\n")
            counts[word] = len(filter(bool, output.split("\n")))
        except subprocess.CalledProcessError:
            pass

    counts['total'] = sum(counts.itervalues())
    doc['swearing'].append(weekly_data(on_date, counts))
Beispiel #3
0
from pycheckup import mapreduce
from pycheckup.document import weekly_data


def run(repo, doc, on_date):
    cmd = ['pep8', repo.working_dir, '-r']

    # pep8 violations show up in stderr.
    # If there are none, return a total of 0.
    try:
        subprocess.check_output(cmd)
        result = {'total': 0}
    except subprocess.CalledProcessError, e:
        result = parse_results(e.output)

    doc['pep8'].append(weekly_data(on_date, result))


def parse_results(results):
    violations = defaultdict(int)

    for line in results.split("\n"):
        try:
            violations[line.split()[1]] += 1
        except IndexError:
            pass

    violations['total'] = sum(violations.itervalues())
    return violations

Beispiel #4
0
def run(repo, doc, on_date):
    doc["line_count"].append(weekly_data(on_date, get_counts(repo)))
Beispiel #5
0
    'UnusedVariable': 'is assigned to but never used'
}


def run(repo, doc, on_date):
    cmd = ['pyflakes', repo.working_dir]

    # Pyflakes violations show up in stderr.
    # If there are none, return a total of 0.
    try:
        subprocess.check_output(cmd, stderr=subprocess.STDOUT)
        result = {'total': 0}
    except subprocess.CalledProcessError, e:
        result = parse_results(e.output)

    doc['pyflakes'].append(weekly_data(on_date, result))


def parse_results(results):
    violations = defaultdict(int)

    for line in results.split("\n"):
        msg = ' '.join(line.split()[1:])

        for error_name, error_search in PYFLAKES_ERRORS.iteritems():
            if error_search in msg:
                violations[error_name] += 1
                break

    violations['total'] = sum(violations.itervalues())
    return violations