def delay(framework, projects, githubtoken):
    print("Computing delay to update")
    path_dos_repositorios = 'repositories'
    measure = "delay"
    output_write(framework, measure, measure, "framework,path,current_version,next_version,framework_release_date (YYYY-DD-MM),sample_update_date (YYYY-DD-MM) ,delay_in_days", True)
    framework_release_data = buscar_dados_de_lancamento_de_versoes(framework, githubtoken)
    configuration_file = define_arquivo_de_configuracao(framework)
    samples = get_samples(projects)
    for index, sample in enumerate(samples):
        print_status_samples(index+1, len(samples))
        sample_path = path_dos_repositorios + "/" + sample
        paths_configuration_file = find_paths(configuration_file, sample_path)
        repository = Repo(sample_path)
        reversed_commits = get_commits(repository)
        for path in paths_configuration_file:
            current_version, reversed_commits = get_first_version(framework, path, repository, reversed_commits)
            if current_version == {}:
                continue
            for commit in reversed_commits:
                repository.git.checkout(commit, '-f')
                next_version = buscar_versao_do_framework(framework, path)
                if current_version != next_version and next_version != '' and current_version != '' and current_version != None and next_version != None:
                    sample_update_date = get_commit_date(commit)
                    framework_release_date = framework_release_data[next_version]
                    delay_in_days = calculate_delay(framework_release_date, sample_update_date)
                    output_write(framework, measure, measure, create_output(current_version, delay_in_days, framework, framework_release_date, next_version, path, sample_update_date), False)
                    current_version = next_version
        repository.git.checkout('master', '-f')
def githubmetadata(framework, projects, githubtoken):
    print("Computing github metadata")
    measure = "githubmetadata"
    output_write(framework, measure, measure, "framework,repository,forks,stargazers,watchers,openedIssues,closedIssues,commits,openedPullRequests,closedPullRequests,updatedAt,projects,lifetime,lifetime per commit", True)
    g = Github(githubtoken)
    samples = get_samples(projects)
    for index, sample in enumerate(samples):
        print_status_samples(index+1, len(samples))
        repo = g.get_repo(sample)
        output = create_output(framework, repo, sample)
        output_write(framework, measure, measure, output, False)
Example #3
0
def forksahead(framework, projects, githubtoken):
    print("Computing forks ahead data")
    g = Github(githubtoken)
    output_write(framework, "forksahead", "forks_ahead_by_projects", "framework,path,number_of_forks,forks_ahead,ratio", True)
    output_write(framework, "forksahead", "forks_ahead", "framework,path,number_of_forks,forks_ahead,ratio", True)
    samples = get_samples(projects)
    for index, sample in enumerate(samples):
        manage_limit_rate(len(samples))
        print_status_samples(index+1, len(samples))
        repository = g.get_repo(sample)
        forks = repository.get_forks()
        forks_ahead = count_forks_ahead(framework, forks, repository)
        number_of_forks = repository.forks_count
        ratio_forks_ahead = forks_ahead / number_of_forks
        output = create_output(sample, framework, number_of_forks, forks_ahead, ratio_forks_ahead)
        output_write(framework, "forksahead", "forks_ahead_by_projects", output, False)
Example #4
0
def importcount(framework, projects):
    print("Computing imports")
    measure = "importcount"
    output_write(framework, measure, measure,
                 "framework,path,imports,javaFiles,imports/java_files", True)
    samples = get_samples(projects)
    for index, sample in enumerate(samples):
        print_status_samples(index + 1, len(samples))
        deal_with_empty_repo(sample)
        java_files_path = find_paths("*.java", "repositories/" + sample)
        imports = get_imports(framework, java_files_path)
        relative = calculate_relative(imports, java_files_path)
        output_write(
            framework, measure, measure,
            create_output(framework, imports, java_files_path, relative,
                          sample), False)
Example #5
0
def numberofextensionfile(framework, projects):
    print("Computing extension files")
    extensions = create_extension_files()
    measure = "numberofextensionfile"
    output_write(
        framework, measure, measure,
        'framework,project,java,properties,jar,build.gradle,pom.xml,manifest.xml,xml,bat,md,adoc,README,yaml,txt,sh,travis.yml,yml,cmd,kt,json,numberOfFiles,others',
        True)
    samples = get_samples(projects)
    for index, sample in enumerate(samples):
        print_status_samples(index + 1, len(samples))
        deal_with_empty_repo(sample)
        count_extension_files(extensions, sample)
        others = count_others(extensions)
        output = concat_output(extensions) + str(others)
        output_write(framework, measure, measure,
                     framework + "," + sample + "," + output, False)
def currentframeworkversion(framework, projects):
    print("Computing current framework version")
    configuration_file = find_config_file(framework)
    configuration_file_key_words = get_key_words(framework)
    write_output_header(configuration_file_key_words, framework)
    samples = get_samples(projects)
    for index, sample in enumerate(samples):
        print_status_samples(index+1, len(samples))
        checkout_default_branch_repository(sample)
        deal_with_empty_repo(sample)
        configuration_files_paths = find_paths(configuration_file, "repositories/" + sample)
        for path in configuration_files_paths:
            output = framework + "," + path
            for key, value in configuration_file_key_words.items():
                version = get_framework_version(framework, path, key)
                output = output + "," + version
            if ",,," not in output and (framework != "spring" or "RELEASE" in output):
                output_write(framework, "currentframeworkversion", "currentframeworkversion", output, False)
def maintainers(framework, projects, githubtoken):
    print("Computing maintainers data")
    output_write(
        framework, "maintainers", "maintainers",
        "framework,path,framework_contributors,sample_contributors,commom_contributors,commom/framework,commom/sample",
        True)
    framework_repository = get_repository_name(framework)
    framework_contributors = get_contributors(framework_repository,
                                              githubtoken)
    framework_contributors.totalCount
    samples = get_samples(projects)
    for index, sample in enumerate(samples):
        print_status_samples(index + 1, len(samples))
        sample_contributors = get_contributors(sample, githubtoken)
        commmom_contributors = get_commom_contributors(framework_contributors,
                                                       sample_contributors)
        output_write(
            framework, "maintainers", "maintainers",
            create_output(framework, sample, framework_contributors,
                          sample_contributors, commmom_contributors), False)
def metrics_by_commits(framework, projects):
    samples = get_samples(projects)
    for index, sample in enumerate(samples):
        print_status_samples(index+1, len(samples))
        owner = sample.split("/")[0]
        create_output_directory("metricsbycommits", owner)
        output_write(sample, "metricsbycommits", "", "framework,path,commits,date,numberOfJavaFiles,countLineCode/numberOfJavaFiles,SumCyclomaticStrict/CountDeclMethod,readability",True)
        repositories_path = "/home/gabriel/Documentos/gabrielsmenezes/pesquisamestrado/repositories/"
        sample_path = repositories_path + sample
        udb_path = "metricsbycommits/" + sample
        commits = get_commits_from(sample)
        commits.reverse()
        ########## é so rodar, esta com a hash certa para o proximo
        # for index, commit in enumerate(commits):
        #     if commit.hexsha == "dfe62cb3e72c7a9cfd759dc7411197d9a629f813":
        #         position = index
        # commits = commits[position+1:]
        for index, commit in enumerate(commits):
            checkout_to(sample, commit.hexsha)
            print("commit ======= " + commit.hexsha)
            metrics = get_metrics(commit, framework, sample, sample_path, udb_path)
            output_write(sample, "metricsbycommits", "", create_output(metrics), False)
            delete_unused_files(sample)
            print("{0}% of commits completed from sample {1}".format((index/len(commits) * 100), sample))