33
Does Code Quality Affect Pull Request Acceptance? An empirical study Valentina Lenarduzzi, Vili Nikkola, Nyyti Saarim¨ aki, Davide Taibi Tampere University, Tampere (Finland) Abstract Background. Pull requests are a common practice for contributing and re- viewing contributions, and are employed both in open-source and industrial contexts. One of the main goals of code reviews is to find defects in the code, allowing project maintainers to easily integrate external contributions into a project and discuss the code contributions. Objective. The goal of this paper is to understand whether code quality is actually considered when pull requests are accepted. Specifically, we aim at understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request code affect the chance of its acceptance when reviewed by a maintainer of the project. Method. We conducted a case study among 28 Java open-source projects, analyzing the presence of 4.7 M code quality issues in 36 K pull requests. We analyzed further correlations by applying Logistic Regression and seven ma- chine learning techniques (Decision Tree, Random Forest, Extremely Ran- domized Trees, AdaBoost, Gradient Boosting, XGBoost). Results. Unexpectedly, code quality turned out not to affect the acceptance of a pull request at all. As suggested by other works, other factors such as the reputation of the maintainer and the importance of the feature deliv- ered might be more important than code quality in terms of pull request acceptance. Conclusions. Researchers already investigated the influence of the devel- opers’ reputation and the pull request acceptance. This is the first work investigating if quality of the code in pull requests affects the acceptance of the pull request or not. We recommend that researchers further investigate Email addresses: [email protected] (Valentina Lenarduzzi), [email protected] (Vili Nikkola), [email protected] (NyytiSaarim¨aki), [email protected] (Davide Taibi) Preprint submitted to Information and Software Technology August 27, 2019 arXiv:1908.09321v1 [cs.SE] 25 Aug 2019

Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

Does Code Quality Affect Pull Request Acceptance? Anempirical study

Valentina Lenarduzzi, Vili Nikkola, Nyyti Saarimaki, Davide Taibi

Tampere University, Tampere (Finland)

Abstract

Background. Pull requests are a common practice for contributing and re-viewing contributions, and are employed both in open-source and industrialcontexts. One of the main goals of code reviews is to find defects in thecode, allowing project maintainers to easily integrate external contributionsinto a project and discuss the code contributions.Objective. The goal of this paper is to understand whether code quality isactually considered when pull requests are accepted. Specifically, we aim atunderstanding whether code quality issues such as code smells, antipatterns,and coding style violations in the pull request code affect the chance of itsacceptance when reviewed by a maintainer of the project.Method. We conducted a case study among 28 Java open-source projects,analyzing the presence of 4.7 M code quality issues in 36 K pull requests. Weanalyzed further correlations by applying Logistic Regression and seven ma-chine learning techniques (Decision Tree, Random Forest, Extremely Ran-domized Trees, AdaBoost, Gradient Boosting, XGBoost).Results. Unexpectedly, code quality turned out not to affect the acceptanceof a pull request at all. As suggested by other works, other factors such asthe reputation of the maintainer and the importance of the feature deliv-ered might be more important than code quality in terms of pull requestacceptance.Conclusions. Researchers already investigated the influence of the devel-opers’ reputation and the pull request acceptance. This is the first workinvestigating if quality of the code in pull requests affects the acceptance ofthe pull request or not. We recommend that researchers further investigate

Email addresses: [email protected] (Valentina Lenarduzzi),[email protected] (Vili Nikkola), [email protected] (Nyyti Saarimaki),[email protected] (Davide Taibi)

Preprint submitted to Information and Software Technology August 27, 2019

arX

iv:1

908.

0932

1v1

[cs

.SE

] 2

5 A

ug 2

019

Page 2: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

this topic to understand if different measures or different tools could providesome useful measures.

Keywords: Pull Requests, SonarQube

1. Introduction

Different code review techniques have been proposed in the past andwidely adopted by open-source and commercial projects. Code reviews in-volve the manual inspection of the code by different developers and helpcompanies to reduce the number of defects and improve the quality of soft-ware [1][2].

Nowadays, code reviews are generally no longer conducted as they werein the past, when developers organized review meetings to inspect the codeline by line [3].

Industry and researchers agree that code inspection helps to reduce thenumber of defects, but that in some cases, the effort required to perform codeinspections hinders their adoption in practice [4]. However, the born of newtools and has enabled companies to adopt different code review practices.In particular, several companies, including Facebook [5], Google [6], andMicrosoft [7], perform code reviews by means of tools such as Gerrit1 or bymeans of the pull request mechanism provided by Git2 [8].

In the context of this paper, we focus on pull requests. Pull requestsprovide developers a convenient way of contributing to projects, and manypopular projects, including both open-source and commercial ones, are usingpull requests as a way of reviewing the contributions of different developers.

Researchers have focused their attention on pull request mechanisms, in-vestigating different aspects, including the review process [9], [10] and [11],the influence of code reviews on continuous integration builds [12], how pullrequests are assigned to different reviewers [13], and in which conditionsthey are accepted process [9],[14],[15],[16]. Only a few works have investi-gated whether developers consider quality aspects in order to accept pullrequests [9],[10]. Different works report that the reputation of the developerwho submitted the pull request is one of the most important acceptancefactors [10],[17].

However, to the best of our knowledge, no studies have investigatedwhether the quality of the code submitted in a pull request has an impact

1https://www.gerritcodereview.com2https://help.github.com/en/articles/about-pull-requests

2

Page 3: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

on the acceptance of this pull request. As code reviews are a fundamentalaspect of pull requests, we strongly expect that pull requests containinglow-quality code should generally not be accepted.

In order to understand whether code quality is one of the acceptancedrivers of pull requests, we designed and conducted a case study involving28 well-known Java projects to analyze the quality of more than 36K pullrequests. We analyzed the quality of pull requests using PMD3, one of thefour tools used most frequently for software analysis [18], [19]. PMD eval-uates the code quality against a standard rule set available for the majorlanguages, allowing the detection of different quality aspects generally con-sidered harmful, including code smells [20] such as ”long methods”, ”largeclass”, ”duplicated code”; anti-patterns [21] such as ”high coupling”; designissues such as ”god class” [22]; and various coding style violations4. When-ever a rule is violated, PMD raises an issue that is counted as part of theTechnical Debt [23]. In the remainder of this paper, we will refer to all theissues raised by PMD as ”TD items” (Technical Debt items).

Previous work confirmed that the presence of several code smells andanti-patterns, including those collected by PMD, significantly increases therisk of faults on the one hand and maintenance effort on the other hand [24],[25], [26], [27].

Unexpectedly, our results show that the presence of TD items of all typesdoes not influence the acceptance or rejection of a pull request at all. Basedon this statement, we analyzed all the data not only using basic statisticaltechniques, but also applying seven machine learning algorithms (LogisticRegression, Decision Tree, Random Forest, Extremely Randomized Trees,AdaBoost, Gradient Boosting, XGBoost), analyzing 36,986 pull requestsand over 4.6 million TD items present in the pull requests.

Structure of the paper. Section 2 describes the basic concepts un-derlying this work, while Section 3 presents some related work done byresearchers in recent years. In Section 4, we describe the design of our casestudy, defining the research questions, metrics, and hypotheses, and de-scribing the study context, including the data collection and data analysisprotocol. In Section 5, we present the achieved results and discuss them inSection 6. Section 7 identifies the threats to the validity of our study, andin Section 8, we draw conclusions and give an outlook on possible futurework.

3https://pmd.github.io4https://pmd.github.io/latest/pmd rules java.html

3

Page 4: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

2. Background

In this Section, we will first introduce code quality aspects and PMD, thetool we used to analyze the code quality of the pull requests. Then we willdescribe the pull request mechanism and finally provide a brief introductionand motivation for the usage of the machine learning techniques we applied.

2.1. Code Quality and PMD

Different tools on the market can be used to evaluate code quality. PMDis one of the most frequently used static code analysis tools for Java on themarket, along with Checkstyle, Findbugs, and SonarQube [18].

PMD is an open-source tool that aims to identify issues that can leadto technical debt accumulating during development. The specified sourcefiles are analyzed and the code is checked with the help of predefined rulesets. PMD provides a standard rule set for major languages, which the usercan customize if needed. The default Java rule set encompasses all availableJava rules in the PMD project and is used throughout this study.

Issues found by PMD have five priority values (P). Rule priority guide-lines for default and custom-made rules can be found in the PMD projectdocumentation 4.

P1 Change absolutely required. Behavior is critically broken/buggy.

P2 Change highly recommended. Behavior is quite likely to be bro-ken/buggy.

P3 Change recommended. Behavior is confusing, perhaps buggy, and/oragainst standards/best practices.

P4 Change optional. Behavior is not likely to be buggy, but more justflies in the face of standards/style/good taste.

P5 Change highly optional. Nice to have, such as a consistent namingpolicy for package/class/fields

These priorities are used in this study to help determine whether moresevere issues affect the rate of acceptance in pull requests.

PMD is the only tool that does not require compiling the code to beanalyzed. This is why, as the aim of our work was to analyze only the codeof pull requests instead of the whole project code, we decided to adopt it.PMD defines more than 300 rules for Java, classified in eight categories (cod-ing style, design, error prone, documentation, multithreading, performance,security). Several rules have also been confirmed harmful by different em-pirical studies. In Table I we highlight a subset of rules and the relatedempirical studies that confirmed their harmfulness. The complete set ofrules is available on the PMD official documentation4.

4

Page 5: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

Table 1: Example of PMD rules and their related harmfulness

PMD Rule Defined By Impacted Characteris-tic

Avoid Using Hard-CodedIP

Brown et al [28] Maintainability [28]

Loose Coupling Chidamber and Kemerer [29] Maintainability [30]

Base Class Should be Ab-stract

Brown et al [28] Maintainability [24]

Coupling Between Objects Chidamber and Kemerer [29] Maintainability [30]

Cyclomatic Complexity Mc Cabe [31] Maintainability [30]

Data Class Fowler [20] Maintainability [32],Faultiness [33], [34]

Excessive Class Length Fowler (Large Class) [20] Change Proneness [35],[36]

Excessive Method Length Fowler (Large Method) [20] Change Proneness [37],[36] Fault Proneness [35]

Excessive Parameter List Fowler (Long ParameterList) [20]

Change Proneness [37]

God Class Marinescu and Lanza [22] Change Pronenes [38],[39], [40], Comprehensi-bility [41],Faultiness [38][40]

Law of Demeter Fowler (Inappropriate Inti-macy) [20]

Change Proneness [35]

Loose Package Coupling Chidamber and Kemerer [29] Maintainability [30]

Comment Size Fowler (Comments) [20] Faultiness [42], [43]

5

Page 6: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

2.2. Git and Pull Requests

Git5 is a distributed version control system that enables users to col-laborate on a coding project by offering a robust set of features to trackchanges to the code. Features include committing a change to a local repos-itory, pushing that piece of code to a remote server for others to see anduse, pulling other developers change sets onto the user’s workstation, andmerging the changes into their own version of the code base. Changes can beorganized into branches, which are used in conjunction with pull requests.Git provides the user a ”diff” between two branches, which compares thebranches and provides an easy method to analyze what kind of additionsthe pull request will bring to the project if accepted and merged into themaster branch of the project.

Pull requests are a code reviewing mechanism that is compatible with Gitand are provided by GitHub6. The goal is for code changes to be reviewedbefore they are inserted into the mainline branch. A developer can take thesechanges and push them to a remote repository on GitHub. Before mergingor rebasing a new feature in, project maintainers in GitHub can review,accept, or reject a change based on the diff of the master code branch andthe branch of the incoming change. Reviewers can comment and vote on thechange in the GitHub web user interface. If the pull request is approved,it can be included in the master branch. A rejected pull request can beabandoned by closing it or the creator can further refine it based on thecomments given and submit it again for review.

2.3. Machine Learning Techniques

In this section, we will describe the machine learning classifiers adoptedin this work. We used eight different classifiers: a generalized linear model(Logistic Regression), a tree-based classifier (Decision Tree), and six ensem-ble classifiers (Bagging, Random Forest, ExtraTrees, AdaBoost, Gradient-Boost, and XGBoost).

In the next sub-sections, we will briefly introduce the eight adoptedclassifiers and give the rationale for choosing them for this study.

Logistic Regression [44] is one of the most frequently used algorithms inMachine Learning. In logistic regression, a collection of measurements (thecounts of a particular issue) and their binary classification (pull requestacceptance) can be turned into a function that outputs the probability of

5https://git-scm.com/6https://github.com/

6

Page 7: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

an input being classified as 1, or in our case, the probability of it beingaccepted.

Decision Tree [45] is a model that takes learning data and constructsa tree-like graph of decisions that can be used to classify new input. Thelearning data is split into subsets based on how the split from the chosenvariable improves the accuracy of the tree at the time. The decisions con-necting the subsets of data form a flowchart-like structure that the modelcan use to tell the user how it would classify the input and how certain theprediction is perceived to be.

We considered two methods for determining how to split the learningdata: GINI impurity and information gain. GINI tells the probability of anincorrect classification of a random element from the subset that has beenassigned a random class within the subset. Information gain tells how muchmore accuracy a new decision node would add to the tree if chosen. GINIwas chosen because of its popularity and its resource efficiency.

Decision Tree as a classifier was chosen because it is easy to implementand human-readable; also, decision trees can handle noisy data well becausesubsets without significance can be ignored by the algorithm that buildsthe tree. The classifier can be susceptible to overfitting, where the modelbecomes too specific to the data used to train it and provides poor resultswhen used with new input data. Overfitting can become a problem whentrying to apply the model to a mode-generalized dataset.

Random Forest [46] is an ensemble classifier, which tries to reduce therisk of overfitting a decision tree by constructing a collection of decision treesfrom random subsets in the data. The resulting collection of decision treesis smaller in depth, has a reduced degree of correlation between the subset’sattributes, and thus has a lower risk of overfitting.

When given input data to label, the model utilizes all the generatedtrees, feeds the input data into all of them, and uses the average of theindividual labels of the trees as the final label given to the input.

Extremely Randomized Trees [47] builds upon the Random Forest intro-duced above by taking the same principle of splitting the data into randomsubsets and building a collection of decision trees from these. In order tofurther randomize the decision trees, the attributes by which the splitting ofthe subsets is done are also randomized, resulting in a more computation-ally efficient model than Random Forest while still alleviating the negativeeffects of overfitting.

Bagging [48] is an ensemble classification technique that tries to reducethe effects of overfitting a model by creating multiple smaller training setsfrom the initial set; in our study, it creates multiple decision trees from

7

Page 8: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

these sets. The sets are created by sampling the initial set uniformly andwith replacements, which means that individual data points can appear inmultiple training sets. The resulting trees can be used in labeling new inputthrough a voting process by the trees.

AdaBoost [49] is a classifier based on the concept of boosting. Theimplementation of the algorithm in this study uses a collection of decisiontrees, but new trees are created with the intent of correctly labeling in-stances of data that were misclassified by previous trees. For each round oftraining, a weight is assigned to each sample in the data. After the round,all misclassified samples are given higher priority in the subsequent rounds.When the number of trees reaches a predetermined limit or the accuracycannot be improved further, the model is finished. When predicting thelabel of a new sample with the finished model, the final label is calculatedfrom the weighted decisions of all the constructed trees. As Adaboost isbased on decision trees, it can be resistant to overfitting and be more usefulwith generalized data. However, Adaboost is susceptible to noise data andoutliers.

Gradient Boost [50] is similar to the other boosting methods. It usesa collection of weaker classifiers, which are created sequentially accordingto an algorithm. In the case of Gradient Boost as used in this study, thedetermining factor in building the new decision trees is the use of a lossfunction. The algorithm tries to minimize the loss function and, similarlyto Adaboost, stops when the model has been fully optimized or the numberof trees reaches the predetermined limit.

XGBoost [51] is a scalable implementation of Gradient Boost. The useof XGBoost can provide performance improvements in constructing a model,which might be an important factor when analyzing a large set of data.

3. Related Work

In this Section, we report on the most relevant works on pull requests.

3.1. Pull Request Process

Pull requests have been studied from different points of view, such aspull-based development [9], [10] and [11], usage of real online resources [12],pull requests reviewer assignment [13], and acceptance process [9], [14], [15],[16]. Another issue regarding pull requests that have been investigated islatency. Yu et al. [52] define latency as a complex issue related to manyindependent variables such as the number of comments and the size of apull request.

8

Page 9: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

Zampetti et al. [12] investigated how, why, and when developers refer toonline resources in their pull requests. They focused on the context and realusage of online resources and how these resources have evolved during time.Moreover, they investigated the browsing purpose of online resources in pullrequest systems. Instead of investigating commit messages, they evaluatedonly the pull request descriptions, since generally the documentation of achange aims at reviewing and possibly accepting the pull request [9].

Yu et al. [13] worked on pull requests reviewer assignment in order toprovide an automatic organization in GitHub that leads to an effort waste.They proposed a reviewer recommender, who should predict highly relevantreviewers of incoming pull requests based on the textual semantics of eachpull request and the social relations of the developers. They found severalfactors that influence pull requests latency such as size, project age, andteam size.

This approach reached a precision rate of 74% for top-1 recommenda-tions, and a recall rate of 71% for top-10 recommendations. However, theauthors did not consider the aspect of code quality. The results are con-firmed also by [15].

Recent studies investigated the factors that influence the acceptance andrejection of a pull request.

There is no difference in treatment of pull-requests coming from the coreteam and from the community. Generally merging decision is postponedbased on technical factors [53],[54]. Generally, pull requests that passed thebuild phase are generally merged more frequently [55]

Integrators decide to accept a contribution after analysing source codequality, code style, documentation, granularity, and adherence to projectconventions [9]. Pull request’s programming language had a significant in-fluence on acceptance [14]. Higher acceptance was mostly found for Scala,C, C#, and R programming languages. Factors regarding developers arerelated to acceptance process, such as the number and experience level ofdevelopers [56], and the developers reputation who submitted the pull re-quest [17]. Moreover, social connection between the pull-request submitterand project manager concerns the acceptance when the core team memberis evaluating the pull-request [57].

Rejection of pull requests can increase when technical problems are notproperly solving and if the number of forks increase too [56]. Other mostimportant rejection factors are inexperience with pull requests; the complex-ity of contributions; the locality of the artifacts modified; and the project’spolicy contribution [15]. From the integrators perspective, social challengesthat needed to be addressed, for example, how to motivate contributors to

9

Page 10: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

keep working on the project and how to explain the reasons of rejection with-out discouraging them. From the contributors perspective, they found thatit is important to reduce response time, maintain awareness, and improvecommunication [9].

3.2. Software Quality of Pull Requests

To the best of our knowledge, only a few studies have focused on thequality aspect of pull request acceptance [9], [10], [16].

Gousios et al. [9] investigated the pull-based development process focus-ing on the factors that affect the efficiency of the process and contribute tothe acceptance of a pull request, and the related acceptance time. They an-alyzed the GHTorrent corpus and another 291 projects. The results showedthat the number of pull requests increases over time. However, the pro-portion of repositories using them is relatively stable. They also identifiedcommon driving factors that affect the lifetime of pull requests and themerging process. Based on their study, code reviews did not seem to in-crease the probability of acceptance, since 84% of the reviewed pull requestswere merged.

Gousios et al. [10] also conducted a survey aimed at characterizing thekey factors considered in the decision-making process of pull request accep-tance. Quality was revealed as one of the top priorities for developers. Themost important acceptance factors they identified are: targeted area im-portance, test cases, and code quality. However, the respondents specifiedquality differently from their respective perception, as conformance, goodavailable documentation, and contributor reputation.

Kononenko et al. [16] investigated the pull request acceptance processin a commercial project addressing the quality of pull request reviews fromthe point of view of developers’ perception. They applied data mining tech-niques on the projects GitHub repository in order to understand the mergenature and then conducted a manual inspection of the pull requests. Theyalso investigated the factors that influence the merge time and outcome ofpull requests such as pull request size and the number of people involvedin the discussion of each pull request. Developers’ experience and affiliationwere two significant factors in both models. Moreover, they report that de-velopers generally associate the quality of a pull request with the quality ofits description, its complexity, and its revertability. However, they did notevaluate the reason for a pull request being rejected. These studies investi-gated the software quality of pull requests focusing on the trustworthinessof developers’ experience and affiliation [16]. Moreover, these studies didnot measure the quality of pull requests against a set of rules, but based on

10

Page 11: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

their acceptance rate and developers’ perception. Our work complementsthese works by analyzing the code quality of pull requests in popular open-source projects and how the quality, specifically issues in the source code,affect the chance of a pull request being accepted when it is reviewed by aproject maintainer. We measured code quality against a set of rules pro-vided by PMD, one of the most frequently used open-source software toolsfor analyzing source code.

4. Case Study Design

We designed our empirical study as a case study based on the guidelinesdefined by Runeson and Host [58]. In this Section, we describe the case studydesign, including the goal and the research questions, the study context, thedata collection, and the data analysis procedure.

4.1. Goal and Research Questions

The goal of this work is to investigate the role of code quality in pullrequest acceptance.

Accordingly, to meet our expectations, we formulated the goal as follows,using the Goal/Question/Metric (GQM) template [59]:

Purpose AnalyzeObject the acceptance of pull requestsQuality with respect to their code qualityViewpoint from the point of view of developersContext in the context of Java projects

Based on the defined goal, we derived the following Research Questions(RQs):

RQ1What is the distribution of TD items violated by the pull requestsin the analyzed software systems?

RQ2Does code quality affect pull request acceptance?RQ3Does code quality affect pull request acceptance considering dif-

ferent types and levels of severity of TD items?

RQ1 aims at assessing the distribution TD items violated by pull re-quests in the analyzed software systems. We also took into account thedistribution of TD items with respect to their priority level as assigned byPMD (P1-P5). These results will also help us to better understand thecontext of our study.

11

Page 12: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

RQ2 aims at finding out whether the project maintainers in open-sourceJava projects consider quality issues in the pull request source code whenthey are reviewing it. If code quality issues affect the acceptance of pullrequests, the question is what kind of TD items errors generally lead to therejection of a pull request.

RQ3 aims at finding out if a severe code quality issue is more likely toresult in the project maintainer rejecting the pull request. This will allowus to see whether project maintainers should pay more attention to specificissues in the code and make code reviews more efficient.

4.2. Context

The projects for this study were selected using ”criterion sampling” [60].The criteria for selecting projects were as follows:

• Uses Java as its primary programming language

• Older than two years

• Had active development in last year

• Code is hosted on GitHub

• Uses pull requests as a means of contributing to the code base

• Has more than 100 closed pull requests

Moreover, we tried to maximize diversity and representativeness consid-ering a comparable number of projects with respect to project age, size, anddomain, as recommended by Nagappan et al. [61].

We selected 28 projects according to these criteria. The majority, 22projects, were selected from the Apache Software Foundation repository7.The repository proved to be an excellent source of projects that meet thecriteria described above. This repository includes some of the most widelyused software solutions, considered industrial and mature, due to the strictreview and inclusion process required by the ASF. Moreover, the includedprojects have to keep on reviewing their code and follow a strict qualityprocess8.

7http://apache.org8https://incubator.apache.org/policy/process.html

12

Page 13: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

The remaining six projects were selected with the help of the TrendingJava repositories list that GitHub provides9. GitHub provides a valuablesource of data for the study of code reviews [62]. In the selection, we man-ually selected popular Java projects using the criteria mentioned before.

In Table 2, we report the list of the 28 projects that were analyzed alongwith the number of pull requests (”#PR”), the time frame of the analysis,and the size of each project (”#LOC”).

4.3. Data Collection

We first extracted all pull requests from each of the selected projectsusing the GitHub REST API v3 10.

For each pull request, we fetched the code from the pull request’s branchand analyzed the code using PMD. The default Java rule set for PMD wasused for the static analysis. We filtered the TD items added in the mainbranch to only include items introduced in the pull request. The filteringwas done with the aid of a diff-file provided by GitHub API and comparedthe pull request branch against the master branch.

We identified whether a pull request was accepted or not by checkingwhether the pull request had been marked as merged into the master branchor whether the pull request had been closed by an event that committed thechanges to the master branch. Other ways of handling pull requests withina project were not considered.

4.4. Data Analysis

The result of the data collection process was a csv file reporting thedependent variable (pull request accepted or not) and the independent vari-ables (number of TD items introduced in each pull request). Table 3 providesan example of the data structure we adopted in the remainder of this work.

For RQ1, we first calculated the total number of pull requests and thenumber of TD items present in each project. Moreover, we calculated thenumber of accepted and rejected pull requests. For each TD item, we cal-culated the number of occurrences, the number of pull requests, and thenumber of projects where it was found. Moreover, we calculated descriptivestatistics (average, maximum, minimum, and standard deviation) for eachTD item.

9https://github.com/trending/java10https://developer.github.com/v3/

13

Page 14: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

Table 2: Selected projects

Project Owner/Name #PR Time Frame #LOC

apache/any23 129 2013/12-2018/11 78.35

apache/dubbo 1,27 2012/02-2019/01 133.63

apache/calcite 873 2014/07-2018/12 337.43

apache/cassandra 182 2018/10-2011/09 411.24

apache/cxf 455 2014/03-2018/12 807.51

apache/flume 180 2012/10-2018/12 103.70

apache/groovy 833 2015/10-2019/01 396.43

apache/guacamole-client 331 2016/03-2018/12 65.92

apache/helix 284 2014/08-2018/11 191.83

apache/incubator-heron 2,19 2015/12-2019/01 207.36

hibernate/hibernate-orm 2,57 2010/10-2019/01 797.30

apache/kafka 5,52 2013/01-2018/12 376.68

apache/lucene-solr 264 2016/01-2018/12 1.416.20

apache/maven 166 2013/03-2018/12 107.80

apache/metamodel 198 2014/09-2018/12 64.80

mockito/mockito 726 2012/11-2019/01 57.40

apache/netbeans 1,02 2017/09-2019/01 6.115.97

netty/netty 4,12 2010/12-2019/01 275.97

apache/opennlp 330 2016/04-2018/12 136.54

apache/phoenix 203 2014/07-2018/12 366.58

apache/samza 1,47 2014/10-2018/10 129.28

spring-projects/spring-framework 1,85 2011/09-2019/01 717.96

spring-projects/spring-boot 3,07 2013/06-2019/01 348.09

apache/storm 2,86 2013/12-2018/12 359.90

apache/tajo 1,020 2014/03-2018/07 264.79

apache/vxquery 169 2015/04-2017/08 264.79

apache/zeppelin 3,19 2015/03-2018/12 218.95

openzipkin/zipkin 1,47 2012/06-2019/01 121.50

Total 36,34 14.683.97

14

Page 15: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

Table 3: Example of data structure used for the analysis

Dependent Variable Independent Variables

Project ID PR ID Accepted PR Rule1 ... Rule n

Cassandra ahkji 1 0 3

Cassandra avfjo 0 0 2

In order to understand if TD items affect pull request acceptance (RQ2),we first determined whether there is a significant difference between theexpected frequencies and the observed frequencies in one or more categories.First, we computed the χ2 test. Then, we selected eight Machine Learningtechniques and compared their accuracy. To overcome to the limitationof the different techniques, we selected and compared eight of them. Thedescription of the different techniques, and the rationale adopted to selecteach of them is reported in Section 2.

χ2 test could be enough to answer our RQs. However, in order to supportpossible follow-up of the work, considering other factors such as LOC asindependent variable, Machine Learning techniques can provide much moreaccuracy results.

We examined whether considering the priority value of an issue affectsthe accuracy metrics of the prediction models (RQ3). We used the sametechniques as before but grouped all the TD items in each project intogroups according to their priorities. The analysis was run separately foreach project and each priority level (28 projects * 5 priority level groups)and the results were compared to the ones we obtained for RQ2. To furtheranalyze the effect of issue priority, we combined the TD items of each prioritylevel into one data set and created models based on all available items withone priority.

Once a model was trained, we confirmed that the predictions about pullrequest acceptance made by the model were accurate (Accuracy Com-parison). To determine the accuracy of a model, 5-fold cross-validationwas used. The data set was randomly split into five parts. A model wastrained five times, each time using four parts for training and the remainingpart for testing the model. We calculated accuracy measures (Precision, Re-call, Matthews Correlation Coefficient, and F-Measure) for each model (seeTable 4) and then combined the accuracy metrics from each fold to producean estimate of how well the model would perform.

We started by calculating the commonly used metrics, including F-measure, precision, recall, and the harmonic average of the latter two. Pre-cision and recall are metrics that focus on the true positives produced by the

15

Page 16: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

Table 4: Accuracy measures

Accuracy Measure Formula

Precision TPFP+TP

Recall TPFN+TP

MCCTP∗TN−FP∗FN√

(FP+TP )(FN−TP )(FP+TN)(FN+TN)

F-measure 2 ∗ precision∗recallprecision+recall

TP: True Positive; TN: True Negative; FP: False Positive; FN: False Negative

model. Powers [63] argues that these metrics can be biased and suggests thata contingency matrix should be used to calculate additional metrics to helpunderstand how negative predictions affect the accuracy of the constructedmodel. Using the contingency matrix, we calculated the model’s MatthewCorrelation Coefficient (MCC), which suggests as the best way to reducethe information provided by the matrix into a single probability describingthe model’s accuracy [63].

For each classifier to easily gauge the overall accuracy of the machinelearning algorithm in a model [64], we calculated the Area Under The Re-ceiver Operating Characteristic (AUC). For the AUC measurement, we cal-culated Receiver Operating Characteristics (ROC) and used these to findout the AUC ratio of the classifier, which is the probability of the classifierranking a randomly chosen positive higher than a randomly chosen negativeone.

4.5. Replicability

In order to allow our study to be replicated, we have published thecomplete raw data in the replication package11.

5. Results

RQ1. What is the distribution of TD items violated by the pull requests inthe analyzed software systems?

For this study, we analyzed 36,344 pull requests violating 253 TD itemsand contained more than 4.7 million times (Table 5) in the 28 analyzed

11https://figshare.com/s/d47b6f238b5c92430dd7

16

Page 17: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

projects. We found that 19,293 pull requests (53.08%) were accepted and17,051 pull requests (46.92%) were rejected. Eleven projects contained thevast majority of the pull requests (80%) and TD items (74%). The distribu-tion of the TD items differs greatly among the pull requests. For example,the projects Cassandra and Phoenix contain a relatively large number of TDitems compared to the number of pull requests, while Groovy, Guacamole,and Maven have a relatively small number of TD items.

Taking into account the priority level of each rule, the vast majority ofTD items (77.86%) are classified with priority level 3, while the remainingones (22.14%) are equally distributed among levels 1, 2, and 4. None of theprojects we analyzed had any issues rated as priority level 5.

Table 6 reports the number of TD items (”#TD item”) and their numberof occurrences (”#occurrences”) grouped by priority level (”Priority”).

Looking at the TD items that could play a role in pull request acceptanceor rejection, 243 of the 253 TD items (96%) are present in both cases, whilethe remaining 10 are found only in cases of rejection (Table 6).

Focusing on TD items that have with a ”double role”, we analyzed thedistribution in each case. We discovered that 88 TD items have a diffusionrate of more than 60% in the case of acceptance and 127 have a diffusionrate of more than 60% in the case of rejection. The remaining 38 are equallydistributed.

Table 8 and Table 9 present preliminary information related to thetwenty most recurrent TD items. We report descriptive statistics by meansof Average (”Avg.”), Maximum (”Max”), Minimum (”Min”), and StandardDeviation (”Std. dev.”). Moreover, we include the priority of each TD item(”Priority”), the sum of issue rows of that rule type found in the issuesmaster table (”# Total occurrences”), and the number of projects in whichthe specific TD item has been violated (”#Project”).

The complete list is available in the replication package (Section 4.5).

17

Page 18: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

Table 5: Distribution of pull requests (PR) and technical debt items (TD items) in theselected projects - (RQ1)

Project Name #PR #TD Items % Acc. % Rej.

apache/any23 129 11,573 90.70 9.30

apache/dubbo 1,270 169,751 52.28 47.72

apache/calcite 873 104,533 79.50 20.50

apache/cassandra 182 153,621 19.78 80.22

apache/cxf 455 62,564 75.82 24.18

apache/flume 180 67,880 60.00 40.00

apache/groovy 833 25,801 81.39 18.61

apache/guacamole-client 331 6,226 92.15 7.85

apache/helix 284 58,586 90.85 9.15

apache/incubator-heron 2,191 138,706 90.32 9.68

hibrenate/hibernate-orm 2,573 490,905 16.27 83.73

apache/kafka 5,522 507,423 73.51 26.49

apache/lucene-solr 264 72,782 28.41 71.59

apache/maven 166 4,445 32.53 67.47

apache/metamodel 198 25,549 78.28 21.72

mockito/mockito 726 57,345 77.41 22.59

apache/netbeans 1,026 52,817 83.14 16.86

netty/netty 4,129 597,183 15.84 84.16

apache/opennlp 330 21,921 82.73 17.27

apache/phoenix 203 214,997 9.85 90.15

apache/samza 1,475 96,915 69.52 30.48

spring-projects/spring-framework

1,850 487,197 15.68 84.32

spring-projects/spring-boot 3,076 156,455 8.03 91.97

apache/storm 2,863 379,583 77.96 22.04

apache/tajo 1,020 232,374 67.94 32.06

apache/vxquery 169 19,033 30.77 69.23

apache/zeppelin 3,194 408,444 56.92 43.08

openzipkin/zipkin 1,474 78,537 73.00 27.00

Total 36,344 4,703,146 19,293 17,051

Table 6: Distribution of TD items in pull requests - (RQ1)

Priority #TD Items #occurrences % PR Acc. % PR Rej.

All 253 4,703,146 96.05 100.00

4 18 85,688 77.78 100.00

3 197 4,488,326 96.95 100.00

2 22 37,492 95.45 95.45

1 16 91,640 100.00 100.00

18

Page 19: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

Summary of RQ1Among the 36,344 analyzed pull requests, we discovered 253 differenttype of TD items (PMD Rules) violated more that 4.7 million times.Nearly half of the pull requests had been accepted and the other halfhad been rejected. 243 of the 253 TD items were found to be presentin both cases. The vast majority of these TD items (197) have prioritylevel 3.

RQ2. Does code quality affect pull request acceptance?

To answer this question, we trained machine learning models for eachproject using all possible pull requests at the time and using all the differentclassifiers introduced in Section 2. A pull request was used if it containedJava that could be analyzed with PMD. There are some projects in thisstudy that are multilingual, so filtering of the analyzable pull requests wasdone out of necessity.

Once we had all the models trained, we tested them and calculated theaccuracy measures described in Table 4 for each model. We then averagedeach of the metrics from the classifiers for the different techniques. Theresults are presented in Table 7. The averaging provided us with an estimateof how accurately we could predict whether maintainers accepted the pullrequest based on the number of different TD items it has. The results of thisanalysis are presented in Table 10. For reasons of space, we report only themost frequent 20 TD items. The table also contains the number of distinctPMD rules that the issues of the project contained. The rule count can beinterpreted as the number of different types of issues found.

Table 7: Model reliability - (RQ2)

Average between 5-fold validation modelsAccuracyMeasure

L. R. D. T. Bagg. R. F. E. T. A. B. G. B. XG.B.

AUC 50.91 50.12 49.83 50.75 50.54 51.30 50.64 50.92

Precision 49.53 48.40 48.56 49.33 49.20 48.74 49.30 49.20

RECALL 62.46 47.45 47.74 48.07 47.74 51.82 41.80 41.91

MCC 0.02 -0.00 0.00 0.01 0.01 0.00 0.00 -0.00

F-Measure 0.55 0.47 0.47 0.48 0.48 0.49 0.44 0.44

19

Page 20: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

Table 8: Descriptive statistics (the 15 most recurrent TD items) - Priority, number ofoccurrences (#occur.), number of Pull Requests (#PR) and number of projects (#prj.)-(RQ1)

TD Item Priority #occur. #PR #prj.

LawOfDemeter 4 1,089,110 15,809 28

MethodArgumentCouldBeFinal 4 627,688 12,822 28

CommentRequired 4 584,889 15,345 28

LocalVariableCouldBeFinal 4 578,760 14,920 28

CommentSize 4 253,447 11,026 28

JUnitAssertionsShouldIncludeMessage 4 196,619 6,738 26

BeanMembersShouldSerialize 4 139,793 8,865 28

LongVariable 4 122,881 8,805 28

ShortVariable 4 112,333 7,421 28

OnlyOneReturn 4 92,166 7,111 28

CommentDefaultAccessModifier 4 58,684 5,252 28

DefaultPackage 4 42,396 4,201 28

ControlStatementBraces 4 39,910 2,689 27

JUnitTestContainsTooManyAsserts 4 3,6022 4,954 26

AtLeastOneConstructor 4 29,516 5,561 28

Table 9: Descriptive statistics (the 15 most recurrent TD items) - Average (Avg.), Maxi-mum (Max), Minimum (Min) and Standard Deviation (std. dev.) - (RQ1)

TD Item Avg Max Min Std. dev.

LawOfDemeter 38,896.785 140,870 767 40,680.62855

MethodArgumentCouldBeFinal 22,417.428 105,544 224 25,936.63552

CommentRequired 20,888.892 66,798 39 21,979.94058

LocalVariableCouldBeFinal 20,670 67394 547 20,461.61422

CommentSize 9,051.678 57,074 313 13,818.66674

JUnitAssertionsShouldIncludeMessage 7,562.269 38,557 58 10822.38435

BeanMembersShouldSerialize 4,992.607 22,738 71 5,597.458969

LongVariable 4,388.607 19,958 204 5,096.238761

ShortVariable 4,011.892 21,900 26 5,240.066577

OnlyOneReturn 3,291.642 14,163 42 3,950.4539

CommentDefaultAccessModifier 2,095.857 12,535 6 2,605.756401

DefaultPackage 1,514.142 9,212 2 1,890.76723

ControlStatementBraces 1,478.148 11,130 1 2,534.299929

JUnitTestContainsTooManyAsserts 1,385.461 7,888 7 1,986.528192

AtLeastOneConstructor 1,054.142 6,514 21 1,423.124177

20

Page 21: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

Table

10:

Sum

mary

of

the

quality

rule

sre

late

dto

pull

reques

tacc

epta

nce

-(R

Q2

and

RQ

3)

Rule

IDP

rior.

#prj

.#

occur.

Imp

ort

ance

(%)

A.B

.B

agg.

D.T

.E

.T.

G.B

.L

.R.

R.F

.X

G.B

.

Law

OfD

emet

er4

28

1089110

0.1

2-0

.51

0.7

7-0

.74

-0.2

9-0

.09

-0.6

60.0

2

Met

hodA

rgum

entC

ould

BeF

inal

428

627688

-0.3

10.3

80.1

40.0

3-0

.71

-0.2

50.2

40.0

7

Com

men

tReq

uir

ed4

28

584889

-0.2

5-0

.11

0.0

7-0

.30

-0.4

7-0

.17

0.5

8-0

.31

Loca

lVari

able

Could

BeF

inal

428

578760

-0.1

3-0

.20

0.5

50.2

80.0

8-0

.05

0.6

1-0

.05

Com

men

tSiz

e4

28

253447

-0.2

4-0

.15

0.4

9-0

.08

-0.1

7-0

.05

-0.1

00.0

5

JU

nit

Ass

erti

onsS

hould

Incl

udeM

essa

ge

426

196619

-0.4

1-0

.84

0.2

2-0

.28

-0.1

9-0

.10

-0.7

50.1

4

Bea

nM

emb

ersS

hould

Ser

ialize

428

139793

-0.3

3-0

.09

-0.0

3-0

.38

-0.3

70.1

70.2

60.0

7

LongV

ari

able

428

122881

0.0

8-0

.19

-0.0

2-0

.25

-0.2

80.0

80.2

40.0

2

Short

Vari

able

428

112333

-0.5

1-0

.24

0.0

9-0

.04

-0.0

40.0

7-0

.25

-0.5

4

Only

OneR

eturn

428

92166

-0.6

9-0

.03

0.0

2-0

.25

-0.0

8-0

.06

0.0

6-0

.13

Com

men

tDef

ault

Acc

essM

odifi

er4

28

58684

-0.1

7-0

.07

0.3

0-0

.41

-0.2

50.2

30.1

8-0

.10

Def

ault

Pack

age

428

42396

-0.3

7-0

.05

0.2

0-0

.23

-0.9

30.1

0-0

.01

-0.5

4

Contr

olS

tate

men

tBra

ces

427

39910

-0.8

90.0

90.5

80.2

9-0

.37

-0.0

30.0

80.2

5

JU

nit

Tes

tConta

insT

ooM

anyA

sser

ts4

26

36022

0.4

00.2

2-0

.25

-0.3

30.0

10.1

60.1

0-0

.17

AtL

east

OneC

onst

ruct

or

428

29516

0.0

0-0

.29

-0.0

6-0

.18

-0.1

9-0

.07

0.1

5-0

.22

Unnec

essa

ryF

ullyQ

ualified

Nam

e4

27

27402

0.0

00.0

80.2

5-0

.05

0.0

00.0

00.2

6-0

.11

Avoid

Duplica

teL

iter

als

428

27224

-0.2

00.0

50.3

3-0

.28

0.1

20.2

00.0

90.0

7

Sig

natu

reD

ecla

reT

hro

wsE

xce

pti

on

427

26188

-0.1

8-0

.10

0.0

4-0

.13

-0.0

50.1

10.3

3-0

.17

Avoid

Inst

anti

ati

ngO

bje

ctsI

nL

oops

328

25344

-0.0

50.0

70.4

3-0

.14

-0.2

7-0

.13

0.5

2-0

.07

Fie

ldN

am

ingC

onven

tions

328

25062

0.0

90.0

00.1

6-0

.21

-0.1

0-0

.01

0.0

70.1

9

21

Page 22: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

Table 11: Contingency matrix

TD items No TD items

PR accepted 10.563 8.558

PR rejected 11.228 5.528

Figure 1: ROC Curves (average between 5-fold validation models) - (RQ2)

As depicted in Figure 1, almost all of the models’ AUC for every methodof prediction hovering around 50%, overall code quality does not appear tobe a factor in determining whether a pull request is accepted or rejected.

There were some projects that showed some moderate success, but thesecan be dismissed as outliers.

The results can suggest that perhaps Machine Learning could not be themost suitable techniques. However, also χ2 test on the contingency matrix(0.12) (Table 11) confirms the above results that the presence of TD itemsdoes not affect pull request acceptance (which means that TD items andpull request acceptance are mutually independent).

RQ3. Does code quality affect pull request acceptance considering differenttypes and levels of severity of TD items?

To answer this research question, we introduced PMD priority valuesassigned to each TD item. By taking these priorities into consideration, we

22

Page 23: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

grouped all issues by their priority value and trained the models using datacomposed of only issues of a certain priority level.

Once we had run the training and tested the models with the datagrouped by issue priority, we calculated the accuracy metrics mentionedabove. These results enabled us to determine whether the prevalence ofhigher-priority issues affects the accuracy of the models. The affect on modelaccuracy or importance is determined with the use of drop-column impor-tance -mechanism12. After training our baseline model with P amount offeatures, we trained P amount of new models and compared each of the newmodels’ tested accuracy against the baseline model. Should a feature affectthe accuracy of the model, the model trained with that feature dropped fromthe dataset would have a lower accuracy score than the baseline model. Themore the accuracy of the model drops with a feature removed, the moreimportant that feature is to the model when classifying pull-requests as ac-cepted or rejected. In table 10 we show the importance of the 20 mostcommon quality rules when comparing the baseline model accuracy with amodel that has the specific quality rule dropped from the feature set.

Grouping by different priority levels did not provide any improvementof the results in terms of accuracy.

Summary of RQ2 and RQ3Looking at the results we obtained from the analysis using statisticaland machine learning techniques (χ2 0.12 and AUC 50% on average),code quality does not appear to influence pull request acceptance.

6. Discussion

In this Section, we will discuss the results obtained according to the RQsand present possible practical implications from our research.

The analysis of the pull requests in 28 well-known Java projects showsthat code quality, calculated by means of PMD rules, is not a driver forthe acceptance or the rejection of pull requests. PMD recommends manualcustomization of the set of rules instead of using the out-of-the-box rule setand selecting the rules that developers should consider in order to maintaina certain level of quality. However, since we analyzed all the rules detectedby PMD, no rule would be helpful and any customization would be useless

12https://explained.ai/rf-importance/

23

Page 24: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

in terms of being able to predict the software quality in code submittedto a pull request. The result cannot be generalized to all the open sourceand commercial projects, as we expect some project could enforce qualitychecks to accept pull requests. Some tools, such as SonarQube (one of themain PMD competitor), recently launched a new feature to allow developersto check the TD Issues before submitting the pull requests. Even if main-tainers are not sensible to the quality of the code to be integrated in theirprojects, at least based on the rules detected by PMD, the adoption of pullrequest quality analysis tools such as SonarQube or the usage of PMD beforesubmitting a pull request will increase the quality of their code, increasingthe overall software maintainability and decreasing the fault proneness thatcould be increased from the injection of some TD items (see Table I).

The results complement those obtained by Soares et al. [15] and Calefatoet al. [17], namely, that the reputation of the developer might be moreimportant than the quality of the code developed. The main implicationfor practitioners, and especially for those maintaining open-source projects,is the realization that they should pay more attention to software quality.Pull requests are a very powerful instrument, which could provide greatbenefits if they were used for code reviews as well. Researchers should alsoinvestigate whether other quality aspects might influence the acceptance ofpull requests.

7. Threats to Validity

In this Section, we will introduce the threats to validity and the differenttactics we adopted to mitigate them,

Construct Validity. This threat concerns the relationship betweentheory and observation due to possible measurement errors. Above all, werelied on PMD, one of the most used software quality analysis tool for Java.However, beside PMD is largely used in industry, we did not find any ev-idence or empirical study assessing its detection accuracy. Therefore, wecannot exclude the presence of false positive and false negative in the de-tected TD items. We extracted the code submitted in pull requests bymeans of the GitHub API10. However, we identified whether a pull requestwas accepted or not by checking whether the pull request had been markedas merged into the master branch or whether the pull request had beenclosed by an event that committed the changes to the master branch. Otherways of handling pull requests within a project were not considered and,therefore, we are aware that there could be the limited possibility that some

24

Page 25: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

maintainer could have integrated the pull request code into their projectsmanually, without marking the pull request as accepted.

Internal Validity. This threat concerns internal factors related to thestudy that might have affected the results. In order to evaluate the codequality of pull requests, we applied the rules provided by PMD, which is oneof the most widely used static code analysis tools for Java on the market,also considering the different severity levels of each rule provided by PMD.We are aware that the presence or the absence of a PMD issue cannot be theperfect predictor for software quality, and other rules or metrics detected byother tools could have brought to different results.

External Validity. This threat concerns the generalizability of the re-sults. We selected 28 projects. 21 of them were from the Apache SoftwareFoundation, which incubates only certain systems that follow specific andstrict quality rules. The remaining six projects were selected with the helpof the trending Java repositories list provided by GitHub. In the selection,we preferred projects that are considered ready for production environmentsand are using pull requests as a way of taking in contributions. Our casestudy was not based only on one application domain. This was avoided sincewe aimed to find general mathematical models for the prediction of the num-ber of bugs in a system. Choosing only one domain or a very small numberof application domains could have been an indication of the non-generalityof our study, as only prediction models from the selected application domainwould have been chosen. The selected projects stem from a very large set ofapplication domains, ranging from external libraries, frameworks, and webutilities to large computational infrastructures. The application domain wasnot an important criterion for the selection of the projects to be analyzed,but at any rate we tried to balance the selection and pick systems from asmany contexts as possible. However, we are aware that other projects couldhave enforced different quality standards, and could use different qualitycheck before accepting pull requests. Furthermore, we are considering onlyopen source projects, and we cannot speculate on industrial projects, asdifferent companies could have different internal practices. Moreover, wealso considered only Java projects. The replication of this work on differentlanguages and different projects may bring to different results.

Conclusion Validity. This threat concerns the relationship betweenthe treatment and the outcome. In our case, this threat could be repre-sented by the analysis method applied in our study. We reported the resultsconsidering descriptive statistics. Moreover, instead of using only LogisticRegression, we compared the prediction power of different classifier to re-duce the bias of the low prediction power that one single classifier could

25

Page 26: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

have. We do not exclude the possibility that other statistical or machinelearning approaches such as Deep Learning or others might have yieldedsimilar or even better accuracy than our modeling approach. However, con-sidering the extremely low importance of each TD Issue and its statisticalsignificance, we do not expect to find big differences applying other type ofclassifiers.

8. Conclusion

Previous works reported 84% of pull requests to be accepted based on thetrustworthiness of the developers [10][17]. However, pull requests are oneof the most common code review mechanisms, and we believe that open-source maintainers are also considering the code quality when accepting orrejecting pull requests.

In order to verify this statement, we analyzed the code quality of pullrequests by means of PMD, one of the most widely used static code analy-sis tools, which can detect different types of quality flaws in the code (TDIssues), including design flaws, code smells, security vulnerability, potentialbugs, and many other issues. We considered PMD as it is able to detecta good number of TD Issues of different types that have been empiricallyconsidered harmful by several works. Examples of these TD Issues are GodClass, High Cyclomatic Complexity, Large Class and Inappropriate Inti-macy.

We applied basic statistical techniques, but also eight machine learningclassifiers to understand if it is possible to predict if a pull request couldbe accepted or not based on the presence of a set of TD Issue in the pullrequest code. Of the 36,344 pull requests we analyzed in 28 well-known Javaprojects, nearly half had been accepted and the other half rejected. 243 ofthe 253 TD items were present in each case.

Unexpectedly, the presence of TD items of all types in the pull requestcode, does not influence the acceptance or rejection of pull requests at alland therefore, the quality of the code submitted in a pull requestdoes not influence at all its acceptance. The same results are verifiedin all the 28 projects independently. Moreover, also merging all the data asa single large data-set confirmed the results.

Our results complement the conclusions derived by Gausios et al. [10]and Calefato et al. [17], who report that the reputation of the developersubmitting the pull request is one of the most important acceptance factors.

As future work, we plan to investigate whether there are other typesof qualities that might affect the acceptance of pull requests, considering

26

Page 27: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

TD Issues and metrics detected by other tool, analyzing different projectswritten in different languages. We also will also investigate how to raiseawareness in the open-source community that code quality should also beconsidered when accepting pull requests.

Moreover, we will understand the perceived harmfulness of developersabout PMD rules, in order to qualitatively assess over these violations. An-other important factor need to be consider is the developers’ personality aspossible influence on the acceptance of the pull request [65].

References

References

[1] A. F. Ackerman, P. J. Fowler, R. G. Ebenau, Software inspectionsand the industrial production of software, in: Proc. Of a Symposiumon Software Validation: Inspection-testing-verification-alternatives, pp.13–40.

[2] A. F. Ackerman, L. S. Buchwald, F. H. Lewski, Software inspections:an effective verification process, IEEE Software 6 (1989) 31–36.

[3] M. E. Fagan, Design and code inspections to reduce errors in programdevelopment, IBM Systems Journal 15 (1976) 182–211.

[4] F. Shull, C. Seaman, Inspecting the history of inspections: An exampleof evidence-based technology diffusion, IEEE Software 25 (2008) 88–90.

[5] D. G. Feitelson, E. Frachtenberg, K. L. Beck, Development and deploy-ment at facebook, IEEE Internet Computing 17 (2013) 8–17.

[6] R. Potvin, J. Levenberg, Why google stores billions of lines of code ina single repository, Commun. ACM 59 (2016) 78–87.

[7] A. Bacchelli, C. Bird, Expectations, outcomes, and challenges of mod-ern code review, in: Proceedings of the 2013 International Conferenceon Software Engineering, ICSE ’13, pp. 712–721.

[8] P. Rigby, B. Cleary, F. Painchaud, M. Storey, D. German, Contem-porary peer review in action: Lessons from open source development,IEEE Software 29 (2012) 56–61.

[9] G. Gousios, M. Pinzger, A. van Deursen, An exploratory study of thepull-based software development model, in: 36th International Confer-ence on Software Engineering, ICSE 2014, pp. 345–355.

27

Page 28: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

[10] G. Gousios, A. Zaidman, M. Storey, A. van Deursen, Work practicesand challenges in pull-based development: The integrator’s perspec-tive, in: 37th IEEE International Conference on Software Engineering,volume 1, pp. 358–368.

[11] E. v. d. Veen, G. Gousios, A. Zaidman, Automatically prioritizing pullrequests, in: 12th Working Conference on Mining Software Reposito-ries, pp. 357–361.

[12] F. Zampetti, L. Ponzanelli, G. Bavota, A. Mocci, M. D. Penta,M. Lanza, How developers document pull requests with external refer-ences, in: 25th International Conference on Program Comprehension(ICPC), volume 00, pp. 23–33.

[13] Y. Yu, H. Wang, G. Yin, C. X. Ling, Reviewer recommender of pull-requests in github, in: IEEE International Conference on SoftwareMaintenance and Evolution, pp. 609–612.

[14] M. M. Rahman, C. K. Roy, An insight into the pull requests of github,in: 11th Working Conference on Mining Software Repositories, MSR2014, pp. 364–367.

[15] D. M. Soares, M. L. d. L. Jnior, L. Murta, A. Plastino, Rejection factorsof pull requests filed by core team developers in software projects withhigh acceptance rates, in: 14th International Conference on MachineLearning and Applications (ICMLA), pp. 960–965.

[16] O. Kononenko, T. Rose, O. Baysal, M. Godfrey, D. Theisen, B. de Wa-ter, Studying pull request merges: A case study of shopify’s activemerchant, in: 40th International Conference on Software Engineering:Software Engineering in Practice, ICSE-SEIP ’18, pp. 124–133.

[17] F. Calefato, F. Lanubile, N. Novielli, A preliminary analysis on theeffects of propensity to trust in distributed software development, in:2017 IEEE 12th International Conference on Global Software Engineer-ing (ICGSE), pp. 56–60.

[18] V. Lenarduzzi, A. Sillitti, D. Taibi, A survey on code analysis tools forsoftware maintenance prediction, in: 6th International Conference inSoftware Engineering for Defence Applications, Springer InternationalPublishing, 2020, pp. 165–175.

28

Page 29: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

[19] M. Beller, R. Bholanath, S. McIntosh, A. Zaidman, Analyzing the stateof static analysis: A large-scale evaluation in open source software, in:23rd International Conference on Software Analysis, Evolution, andReengineering (SANER), volume 1, pp. 470–481.

[20] M. Fowler, K. Beck, Refactoring: Improving the design of existing code,Addison-Wesley Longman Publishing Co., Inc. (1999).

[21] W. J. Brown, R. C. Malveau, H. W. S. McCormick, T. J. Mowbray, An-tiPatterns: Refactoring Software, Architectures, and Projects in Crisis:Refactoring Software, Architecture and Projects in Crisis, John Wileyand Sons, 1998.

[22] M. Lanza, R. Marinescu, S. Ducasse, Object-Oriented Metrics in Prac-tice, Springer-Verlag, Berlin, Heidelberg, 2005.

[23] W. Cunningham, The wycash portfolio management system, OOPSLA’92.

[24] F. Khomh, M. Di Penta, Y. Gueheneuc, An exploratory study of theimpact of code smells on software change-proneness, in: 2009 16thWorking Conference on Reverse Engineering, pp. 75–84.

[25] S. Olbrich, D. S. Cruzes, V. Basili, N. Zazworka, The evolution andimpact of code smells: A case study of two open source systems, in:2009 3rd International Symposium on Empirical Software Engineeringand Measurement, pp. 390–400.

[26] M. D’Ambros, A. Bacchelli, M. Lanza, On the impact of design flawson software defects, in: 2010 10th International Conference on QualitySoftware, pp. 23–31.

[27] F. Fontana Arcelli, S. Spinelli, Impact of refactoring on quality codeevaluation, in: Proceedings of the 4th Workshop on Refactoring Tools,WRT ’11, pp. 37–40.

[28] W. H. Brown, R. C. Malveau, H. W. S. McCormick, T. J. Mowbray, An-tiPatterns: Refactoring Software, Architectures, and Projects in Crisis,New York, NY, USA, 1st edition, 1998.

[29] S. R. Chidamber, C. F. Kemerer, A metrics suite for object orienteddesign, IEEE Trans. Softw. Eng. 20 (1994) 476–493.

29

Page 30: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

[30] J. Al Dallal, A. Abdin, Empirical evaluation of the impact of object-oriented code refactoring on quality attributes: A systematic literaturereview, IEEE Transactions on Software Engineering 44 (2018) 44–69.

[31] T. J. McCabe, A complexity measure, IEEE Trans. Softw. Eng. 2(1976) 308–320.

[32] W. Li, R. Shatnawi, An empirical study of the bad smells and classerror probability in the post-release object-oriented system evolution,J. Syst. Softw. 80 (2007) 1120–1128.

[33] D. I. K. Sjberg, A. Yamashita, B. C. D. Anda, A. Mockus, T. Dyb,Quantifying the effect of code smells on maintenance effort, IEEETransactions on Software Engineering 39 (2013) 1144–1156.

[34] A. Yamashita, Assessing the capability of code smells to explain mainte-nance problems: An empirical study combining quantitative and qual-itative data, Empirical Softw. Engg. 19 (2014) 1111–1143.

[35] F. Palomba, G. Bavota, M. D. Penta, F. Fasano, R. Oliveto, A. D.Lucia, On the diffuseness and the impact on maintainability of codesmells: A large scale empirical investigation, Empirical Softw. Engg.23 (2018) 1188–1221.

[36] F. Khomh, M. Di Penta, Y. Gueheneuc, An exploratory study of theimpact of code smells on software change-proneness, in: 2009 16thWorking Conference on Reverse Engineering, pp. 75–84.

[37] F. Jaafar, Y.-G. Gueheneuc, S. Hamel, F. Khomh, M. Zulkernine, Eval-uating the impact of design pattern and anti-pattern dependencies onchanges and faults, Empirical Softw. Engg. 21 (2016) 896–931.

[38] S. M. Olbrich, D. S. Cruzes, D. I. K. Sjberg, Are all code smells harmful?a study of god classes and brain classes in the evolution of three opensource systems, in: 2010 IEEE International Conference on SoftwareMaintenance, pp. 1–10.

[39] J. Schumacher, N. Zazworka, F. Shull, C. Seaman, M. Shaw, Buildingempirical support for automated code smell detection, in: Proceedingsof the 2010 ACM-IEEE International Symposium on Empirical Soft-ware Engineering and Measurement, ESEM ’10, pp. 8:1–8:10.

30

Page 31: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

[40] N. Zazworka, M. A. Shaw, F. Shull, C. Seaman, Investigating theimpact of design debt on software quality, in: Proceedings of the 2NdWorkshop on Managing Technical Debt, MTD ’11, pp. 17–23.

[41] B. Du Bois, S. Demeyer, J. Verelst, T. Mens, M. Temmerman, Doesgod class decomposition affect comprehensibility?, pp. 346–355.

[42] H. Aman, S. Amasaki, T. Sasaki, M. Kawahara, Empirical analysisof fault-proneness in methods by focusing on their comment lines, in:2014 21st Asia-Pacific Software Engineering Conference, volume 2, pp.51–56.

[43] H. Aman, An empirical analysis on fault-proneness of well-commentedmodules, in: 2012 Fourth International Workshop on Empirical Soft-ware Engineering in Practice, pp. 3–9.

[44] D. R. Cox, The regression analysis of binary sequences, Journal of theRoyal Statistical Society. Series B (Methodological) 20 (1958) 215–242.

[45] L. Breiman, J. Friedman, C. Stone, R. Olshen, Classification and Re-gression Trees, The Wadsworth and Brooks-Cole statistics-probabilityseries, Taylor and Francis, 1984.

[46] L. Breiman, Random forests, Machine Learning 45 (2001) 5–32.

[47] P. Geurts, D. Ernst, L. Wehenkel, Extremely randomized trees, Ma-chine Learning 63 (2006) 3–42.

[48] L. Breiman, Bagging predictors, Machine Learning 24 (1996) 123–140.

[49] Y. Freund, R. E. Schapire, A decision-theoretic generalization of on-line learning and an application to boosting, Journal of Computer andSystem Sciences 55 (1997) 119 – 139.

[50] J. H. Friedman, Greedy function approximation: A gradient boostingmachine., Ann. Statist. 29 (2001) 1189–1232.

[51] T. Chen, C. Guestrin, Xgboost: A scalable tree boosting system, in:Proceedings of the 22Nd ACM SIGKDD International Conference onKnowledge Discovery and Data Mining, pp. 785–794.

[52] Y. Yu, H. Wang, V. Filkov, P. Devanbu, B. Vasilescu, Wait for it:Determinants of pull request evaluation latency on github, in: 12thWorking Conference on Mining Software Repositories, pp. 367–371.

31

Page 32: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

[53] V. J. Hellendoorn, P. T. Devanbu, A. Bacchelli, Will they like this?evaluating code contributions with language models, in: 12th WorkingConference on Mining Software Repositories, pp. 157–167.

[54] P. C. Rigby, M. Storey, Understanding broadcast based peer reviewon open source software projects, in: 33rd International Conference onSoftware Engineering (ICSE), pp. 541–550.

[55] F. Zampetti, G. Bavota, G. Canfora, M. Di Penta, A study on theinterplay between pull request review and continuous integration builds,pp. 38–48.

[56] M. M. Rahman, C. K. Roy, J. A. Collins, Correct: Code reviewerrecommendation in github based on cross-project and technology ex-perience, in: 38th International Conference on Software EngineeringCompanion (ICSE-C), pp. 222–231.

[57] J. Tsay, L. Dabbish, J. Herbsleb, Influence of social and technicalfactors for evaluating contribution in github, in: 36th InternationalConference on Software Engineering, ICSE 2014, pp. 356–366.

[58] P. Runeson, M. Host, Guidelines for conducting and reporting casestudy research in software engineering, Empirical Softw. Engg. 14(2009) 131–164.

[59] V. R. Basili, G. Caldiera, H. D. Rombach, The goal question metricapproach, Encyclopedia of Software Engineering (1994).

[60] M. Patton, Qualitative Evaluation and Research Methods, Sage, New-bury Park, 2002.

[61] M. Nagappan, T. Zimmermann, C. Bird, Diversity in software engi-neering research, ESEC/FSE 2013, pp. 466–476.

[62] E. Kalliamvakou, G. Gousios, K. Blincoe, L. Singer, D. M. German,D. Damian, An in-depth study of the promises and perils of mininggithub, Empirical Software Engineering 21 (2016) 2035–2071.

[63] D. Powers, Evaluation: From precision, recall and f-factor to roc, in-formedness, markedness & correlation, Mach. Learn. Technol. 2 (2008).

[64] A. P. Bradley, The use of the area under the roc curve in the evaluationof machine learning algorithms, Pattern Recognition 30 (1997) 1145 –1159.

32

Page 33: Does Code Quality A ect Pull Request Acceptance? An ... · understanding whether code quality issues such as code smells, antipatterns, and coding style violations in the pull request

[65] F. Calefato, F. Lanubile, B. Vasilescu, A large-scale, in-depth analysisof developers personalities in the apache ecosystem, Information andSoftware Technology 114 (2019) 1 – 20.

33