### Deploying LibRepair Data API Source: https://github.com/eclipse-repairnator/repairnator/blob/master/website/repairnator-mongo-rest-api/README.md Provides a step-by-step guide to deploy the LibRepair Data API, including environment setup, compilation to ES5, transferring compiled files to a server, installing production dependencies, and starting the service using a process manager like PM2. ```Shell # create the proper env file (needed for the MongoDB credentials) cp .env.example .env # compile to ES5 yarn build # upload dist/ to your server scp -rp dist/ user@dest:/path # install production dependencies only yarn --production # Use any process manager to start your services pm2 start dist/index.js ``` -------------------------------- ### Flacoco Scanner: Full Setup and Execution Example Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/main-classes.md A complete guide to setting up and running Flacoco Scanner. This snippet demonstrates how to configure necessary environment variables (Maven home, GitHub token, project list, result repository, scan parameters), clone the Repairnator project, build it using Maven, and finally execute the Flacoco Scanner application. ```Shell export M2_HOME=/usr/share/maven export GITHUB_TOKEN=foobar # Your Token export PROJECTS_TO_SCAN_FILE=/path/to/file.txt export FLACOCO_RESULTS_REPOSITORY=/ # Only to save the results in a repository export FLACOCOBOT_SCAN_INTERVAL=60 # Minutes export FLACOCOBOT_EXECUTION_TIME=10 # Days export FLACOCOBOT_CHECK_PR_DAYS_BEFORE_CURRENT_DATE=30 # Days git clone https://github.com/eclipse/repairnator/ cd repairnator mvn clean install -DskipTests -f src/repairnator-core/ && mvn clean install -DskipTests -f src/repairnator-pipeline/ cd src/repairnator-realtime mvn clean package -DskipTests java -cp target/repairnator-realtime--jar-with-dependencies.jar fr.inria.spirals.repairnator.realtime.FlacocoScanner --ghOauth $GITHUB_TOKEN ``` -------------------------------- ### Install shUnit2 testing framework Source: https://github.com/eclipse-repairnator/repairnator/blob/master/src/docker-images/checkbranches-dockerimage/README.md This snippet provides commands to install the shUnit2 testing framework on different operating systems. It covers Debian/Ubuntu Linux using `apt-get` and macOS using `brew`. ```bash $ sudo apt-get install shunit2 # for debian/ubuntu linux $ brew install shunit2 # for macos ``` -------------------------------- ### Run Repairnator GitHub App Locally Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/repairnator-github-app.md Instructions to set up and run the Repairnator GitHub App locally. This involves navigating to the application directory, installing Node.js dependencies, and starting the application. Requires a `.env` file with a Travis API Token and Webhook Secret. ```Shell cd src/repairnator-github-app/ # Install Node.js dependencies npm install # Run the bot npm start ``` -------------------------------- ### Deploying the librepair-site Website Source: https://github.com/eclipse-repairnator/repairnator/blob/master/website/repairnator-site/README.md This snippet provides the steps to deploy the librepair website. It covers installing global dependencies like gulp and bower, installing project-specific dependencies, copying and editing configuration files, running gulp to build the site, and finally copying the generated distribution files to the web server directory. Users should be aware of changing the API URL in the config files if deploying to a different environment. ```shell # install gulp and bower $ npm install -g gulp bower # install dependencies $ npm install $ bower install # copy the config files (and edit them) $ cp -r config.exemple config # run gulp $ gulp # Copy the dist directory content $ cp dist/* /var/www/website ``` -------------------------------- ### Install shUnit2 for Testing Shell Scripts Source: https://github.com/eclipse-repairnator/repairnator/blob/master/src/docker-images/bears-checkbranches-dockerimage/README.md This snippet provides commands to install the shUnit2 testing framework. It includes commands for Debian/Ubuntu Linux using apt-get and for macOS using brew. shUnit2 is required to run the tests for check_branches.sh. ```bash $ sudo apt-get install shunit2 # for debian/ubuntu linux $ brew install shunit2 # for macos ``` -------------------------------- ### Run ActiveMQ Service Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/repairnator-github-app.md Instructions to download, configure, and start the ActiveMQ service. This includes modifying the admin password, switching the conversion strategy in `activemq.xml`, and starting the service. It also provides the URL for the web console. ```Shell # 1. Download and unzip ActiveMQ (e.g., to your home folder) # Example: wget https://archive.apache.org/dist/activemq/5.15.11/apache-activemq-5.15.11-bin.tar.gz # tar -xzf apache-activemq-5.15.11-bin.tar.gz # 2. Modify admin password in apache-activemq-5.15.11/conf/jetty-realm.properties (recommended) # 3. Modify ActiveMQ configuration in apache-activemq-5.15.11/conf/activemq.xml (recommended): # Locate the AMQP transport connector and change its URI: # FROM: # TO: # 4. Navigate to the ActiveMQ bin directory and start the service cd ~/apache-activemq-5.15.11/bin ./activemq start # 5. Access the ActiveMQ web console at http://{ip}:8161/admin/ ``` -------------------------------- ### Setup Repairnator for Command Line Usage Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/main-classes.md Instructions to clone the Repairnator repository, navigate into it, and build the core and pipeline modules using Maven. This prepares the project for execution. ```bash $ git clone https://github.com/eclipse/repairnator/ $ cd repairnator/ $ mvn clean install -DskipTests -f src/repairnator-core/ && mvn clean install -DskipTests -f src/repairnator-pipeline/ $ cd src/repairnator-pipeline/ ``` -------------------------------- ### Setting up Mocha and Chai for BDD Testing Source: https://github.com/eclipse-repairnator/repairnator/blob/master/website/repairnator-site/test/index.html This JavaScript snippet configures the Mocha test framework for Behavior-Driven Development (BDD) style testing and initializes Chai's assertion libraries (assert, expect, should). It also includes a conditional check to run Mocha only if the environment is not PhantomJS, which is common in browser-based testing setups. ```JavaScript mocha.setup('bdd'); var assert = chai.assert; var expect = chai.expect; var should = chai.should(); if (navigator.userAgent.indexOf('PhantomJS') === -1) { mocha.run(); } ``` -------------------------------- ### Run Repairnator-bot NodeJS Server Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/repairnator-github-app.md Steps to start the Repairnator-bot NodeJS server. This includes cloning the repository, ensuring necessary configuration files (`.env`, `.private-key.pem`) are in place, and running the server in the background using `nohup`. ```Shell # 1. Clone the repairnator-bot repository # (e.g., git clone ) # 2. Add .env and .private-key.pem files # (These files contain sensitive information and should be created/placed manually) # 3. Navigate to the repository directory cd ~/repairnator-bot # 4. Run the NodeJS server in the background nohup npm start & ``` -------------------------------- ### Run check_branches.sh Tests Source: https://github.com/eclipse-repairnator/repairnator/blob/master/src/docker-images/bears-checkbranches-dockerimage/README.md This command executes the check_branches_test.sh script, which contains the tests for check_branches.sh. Ensure shUnit2 is installed and the test script has execute permissions before running. ```bash $ ./check_branches_test.sh ``` -------------------------------- ### Manually Install Maven Repair Plugin Source: https://github.com/eclipse-repairnator/repairnator/blob/master/src/maven-repair/README.md Instructions to manually clone the `repairnator` repository, navigate to the `maven-repair` module, and install the plugin into your local Maven repository. ```bash git clone https://github.com/eclipse/repairnator cd src/maven-repair mvn install ``` -------------------------------- ### Example Output of Maven Repair with Nopol Source: https://github.com/eclipse-repairnator/repairnator/blob/master/src/maven-repair/README.md An example of the console output when `maven-repair` successfully finds a patch using Nopol. It shows the detected patch, the number of tests executing it, the affected class and line, and the diff of the proposed fix. ```text [INFO] ----PATCH FOUND---- [INFO] className.length() == 0 [INFO] Nb test that executes the patch: 37 [INFO] org.apache.commons.lang.ClassUtils:258: CONDITIONAL [INFO] --- a/src/java/org/apache/commons/lang/ClassUtils.java +++ b/src/java/org/apache/commons/lang/ClassUtils.java @@ -257,3 +257,3 @@ public static String getPackageName(String className) { - if (className == null) { + if (className.length() == 0) { return StringUtils.EMPTY; Nopol executed after: 14233 ms. ``` -------------------------------- ### Run Repairnator on a Travis CI Build Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/main-classes.md This snippet demonstrates how to execute the Repairnator Launcher on a specific Travis CI build. It requires setting environment variables for Maven home, a GitHub token, and the path to tools.jar from a JDK installation. ```bash export M2_HOME=/usr/share/maven export GITHUB_TOKEN=foobar # your Token export TOOLS_JAR=/usr/lib/jvm/default-java/lib/tools.jar java -cp $TOOLS_JAR:target/repairnator-pipeline-3.3-SNAPSHOT-jar-with-dependencies.jar fr.inria.spirals.repairnator.pipeline.Launcher --ghOauth $GITHUB_TOKEN -b 224246334 ``` -------------------------------- ### Refactoring Java: Remove Unused Variables and Improve Loop Efficiency Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/sobo/templates/body/S1481.md This snippet demonstrates how to improve Java code by eliminating unused variables and optimizing loop constructs. The 'Instead of' example shows common pitfalls like declaring variables that are never used and an unclear loop iterator. The 'Do this' example provides a cleaner, more efficient alternative for counting elements in a list, promoting better readability and maintainability. ```java /** * Count the number of sheep in a list * */ public static int countSheep(List sheeps){ int wolves=0; // unused variable! String = "Zzz..."; // unused variable! int numberOfSheep=0; for(Sheep s : sheeps) { // is 's' unused? 🤔 numberOfSheep++; } return numberOfSheep; } ``` ```java /** * Count the number of sheep in a list * */ public static int countSheep(List sheeps){ int numberOfSheep=0; for(int i = 0; i < sheeps.size(); i++) { numberOfSheep++; } return numberOfSheep; } ``` -------------------------------- ### Example Glossary JSON Data Structure Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/sobo/templates/honey.md This JSON snippet illustrates the structure for a glossary, containing a single entry with details such as ID, term, acronym, abbreviation, definition count, related tasks, and lecturer information. It serves as a template for defining structured glossary data within the 'eclipse-repairnator/repairnator' project context. ```JSON { "glossary": { "title": "INDA-FALL-22", "GlossDiv": { "title": "{task}", "GlossList": { "GlossEntry": { "ID": "SVBP", "SortAs": "LEADER-DEVOP", "GlossTerm": "Automatic Feedback Generation", "Acronym": "SOBO", "Abbrev": "ISO 8879:1986", "GlossDef": { "count": 151, "GlossSeeAlso": ["task-2", "task-3"] }, "LECTURER": "RIC GLASSEY" } } } } } ``` -------------------------------- ### Refactoring Java: Counting Sheep for Improved Maintainability Source: https://github.com/eclipse-repairnator/repairnator/blob/master/src/repairnator-pipeline/src/main/java/fr/inria/spirals/repairnator/process/step/feedback/sobo/templates/body/S1481.md This snippet demonstrates how to refactor a Java method to improve code quality and maintainability. The 'bad' example illustrates the use of unused variables and a less explicit loop, while the 'good' example provides a cleaner, more efficient implementation for counting items in a list, adhering to best practices for variable usage and loop iteration. ```java /** * Count the number of sheep in a list * */ public static int countSheep(List sheeps){ int wolves=0; // unused variable! String = "Zzz..."; // unused variable! int numberOfSheep=0; for(Sheep s : sheeps) { // is 's' unused? 🤔 numberOfSheep++; } return numberOfSheep; } ``` ```java /** * Count the number of sheep in a list * */ public static int countSheep(List sheeps){ int numberOfSheep=0; for(int i = 0; i < sheeps.size(); i++) { numberOfSheep++; } return numberOfSheep; } ``` -------------------------------- ### GITHUB_OAUTH Configuration Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/repairnator-config.md This attribute is mandatory. It is used to get access to GitHub API. In order to create the token, go to the following page: https://github.com/settings/tokens and create a new token by selecting `public_repo`. ```APIDOC GITHUB_OAUTH: Mandatory: true Description: Used to get access to GitHub API. Create token at https://github.com/settings/tokens by selecting `public_repo`. ``` -------------------------------- ### NPEFix JSON Output Structure Example Source: https://github.com/eclipse-repairnator/repairnator/blob/master/src/maven-repair/README.md This JSON snippet illustrates the output format generated by NPEFix, a repair tool. It details individual execution laps, including error information, location of decision points, associated tests, and the decisions made during each lap. It also provides a 'searchSpace' array listing all detected decisions. ```js { "executions": [ /* all laps */ { "result": { "error": "", "type": "", "success": true }, /* all decisions points */ "locations": [{ "sourceEnd": 12234, "executionCount": 0, "line": 352, "class": "org.apache.commons.collections.iterators.CollatingIterator", "sourceStart": 12193 }], /* the runned test */ "test": { "name": "testNullComparator", "class": "org.apache.commons.collections.iterators.TestCollatingIterator" }, /* all decision made during the laps */ "decisions": [{ /* the location of the laps */ "location": { "sourceEnd": 12234, "line": 352, "class": "org.apache.commons.collections.iterators.CollatingIterator", "sourceStart": 12193 }, /* the value used by the decision */ "value": { "variableName": "leastObject", "value": "leastObject", "type": "int" }, /* the value of the epsilon */ "epsilon": 0.4, // the name of the strategy "strategy": "Strat4 VAR", "used": true, /* the decision type (new, best, random) */ "decisionType": "new" }], "startDate": 1453918743999, "endDate": 1453918744165, "metadata": {"seed": 10} }, ... ], "searchSpace": [ /* all detected decisions */ { "location": { "sourceEnd": 12234, "line": 352, "class": "org.apache.commons.collections.iterators.CollatingIterator", "sourceStart": 12193 }, "value": { "value": "1", "type": "int" }, "epsilon": 0, "strategy": "Strat4 NEW", "used": false, "decisionType": "random" }, ... ], "date": "Wed Jan 27 19:19:37 CET 2016" } ``` -------------------------------- ### API Endpoint: Get Patches by Build ID Source: https://github.com/eclipse-repairnator/repairnator/blob/master/website/repairnator-mongo-rest-api/README.md Retrieves a list of patch entries associated with a specific `buildId`. ```APIDOC GET /patches/builds/:buildId Description: Returns a list of patches for the given 'buildId'. Parameter: buildId (string) - The ID of the build. ``` -------------------------------- ### API Endpoint: Get All Scanners Data Source: https://github.com/eclipse-repairnator/repairnator/blob/master/website/repairnator-mongo-rest-api/README.md Retrieves all data from the 'scanner' collection. This endpoint should be used carefully due to the large volume of data it returns. ```APIDOC GET /scanners/ Description: Returns the entire 'scanner' collection data. Warning: This endpoint returns a large amount of data. ``` ```json [ { "_id": "5a5f3ccf7bb0706d6090d76f", "hostname": "spirals-librepair", "dateBeginStr": "17/01/18 13:01", "dateBegin": "2018-01-17T13:01:55.625Z", "dateLimitStr": "17/01/18 12:01", "dateLimit": "2018-01-17T12:01:55.623Z", "dayLimit": "17/01/2018", "totalRepoNumber": 281, "totalRepoUsingTravis": 276, "totalScannedBuilds": 35, "totalJavaBuilds": 33, "totalJavaPassingBuilds": 18, "totalJavaFailingBuilds": 5, "totalJavaFailingBuildsWithFailingTests": 4, "totalPRBuilds": 16, "duration": "0:6:52", "runId": "b4610a57-1ed2-4204-a6a1-114d6e2bb603" }, { "_id": "5a5f2ea6addee75da1c25332", "hostname": "spirals-librepair", "dateBeginStr": "17/01/18 12:01", "dateBegin": "2018-01-17T12:01:29.830Z", "dateLimitStr": "17/01/18 11:01", "dateLimit": "2018-01-17T11:01:29.829Z", "dayLimit": "17/01/2018", "totalRepoNumber": 281, "totalRepoUsingTravis": 276, "totalScannedBuilds": 70, "totalJavaBuilds": 62, "totalJavaPassingBuilds": 24, "totalJavaFailingBuilds": 4, "totalJavaFailingBuildsWithFailingTests": 3, "totalPRBuilds": 28, "duration": "0:6:52", "runId": "bb8f300f-fa61-48a1-a8a8-70f8cf44e6e5" } ] ``` -------------------------------- ### Demonstrating Java Class Member Order Conventions Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/sobo/templates/body/S1213.md This example illustrates the standard Java convention for ordering class members within a source file. It presents both an incorrect arrangement, where constructors and static variables are misplaced, and a correct arrangement, adhering to the recommended order of fields, constructors, and methods. ```Java public class Indamon{ private int hp= 0; public boolean isFainted() {...} public Indamon() {...} // Constructor defined after methods public static final int LEGS= 4; //Variable defined after constructors and methods } ``` ```Java public class Indamon{ //fields public static final int LEGS= 4; private int hp= 0; //constructors public Indamon() {...} //methods public boolean isFainted() {...} } ``` -------------------------------- ### Executing Maven Goals in Repairnator Steps Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/add-repair-tool.md This example shows how to execute a Maven goal from a plugin within a Repairnator step using `MavenHelper`. It illustrates setting the goal, providing properties, enabling log handlers, and checking the execution status. Note that the Maven Plugin must be released on Maven Central. ```java String goalOfMyPlugin = "my.plugin:mygoal"; Properties properties = new Properties(); // put some properties if needed boolean enableHandlers = true; // if false logs are mute, else they will be displayed MavenHelper mavenHelper = new MavenHelper(this.getPom(), goalOfMyPlugin, properties, this.getRepairToolName(), this.getInspector(), enableHandlers); int status = MavenHelper.MAVEN_ERROR; try { status = mavenHelper.run(); } catch (InterruptedException e) { this.addStepError("Error while executing Maven goal", e); } if (status == MAVEN_ERROR) { // some stuff } else { // success } ``` -------------------------------- ### Compile Repairnator Jenkins Plugin Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/repairnator-jenkins-plugin.md Instructions to directly compile the Repairnator Jenkins plugin using Maven. This command navigates to the plugin's source directory and executes the Maven install goal, skipping tests. The resulting 'hpi' file will be located in the 'target/' folder. ```Bash cd src/repairnator-jenkins-plugin mvn install -DskipTests ``` -------------------------------- ### MongoDB query for test-failure builds Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/scripts.md This query retrieves the count of builds with 'failed' status and test-failures on Travis CI within a specified date range from the `rtscanner` collection. The date range is inclusive for the start date and exclusive for the end date. ```APIDOC db.rtscanner.find({$and :[ {dateWatched:{$gte:ISODate("2018-01-01T00:00:00Z"),$lt:ISODate("2018-06-30T23:59:59Z")}},{status:"failed"}]}).count() ``` -------------------------------- ### Run Repairnator on a Specific Git Branch Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/main-classes.md This example illustrates how to instruct Repairnator to operate on a particular branch of a Git repository. Using --gitrepobranch allows focusing the analysis on a specific development line, and it can be combined with commit-specific options. ```bash export M2_HOME=/usr/share/maven export GITHUB_TOKEN=foobar # your Token export TOOLS_JAR=/usr/lib/jvm/default-java/lib/tools.jar java -cp $TOOLS_JAR:target/repairnator-pipeline-3.3-SNAPSHOT-jar-with-dependencies.jar fr.inria.spirals.repairnator.pipeline.Launcher --ghOauth $GITHUB_TOKEN --launcherMode GIT_REPOSITORY --gitrepourl --gitrepobranch ``` -------------------------------- ### Activate NpeFIX for NullPointerException Repair in Maven POM Source: https://github.com/eclipse-repairnator/repairnator/blob/master/src/maven-repair/README.md Configure your Maven `pom.xml` to automatically activate the NpeFIX repair tool during the `test` phase. This setup also includes necessary `maven-surefire-plugin` configurations to ignore test failures and preserve stack traces, which are crucial for repair tool operation. ```xml org.apache.maven.plugins maven-surefire-plugin true false fr.inria.gforge.spirals repair-maven-plugin test npefix ``` -------------------------------- ### Launch Repairnator Flacoco Scanner Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/README.md This snippet provides instructions to set up and run the Repairnator Flacoco Scanner. It requires Java and Docker. The process involves cloning the repository, building the `repairnator-realtime` module with Maven, and then executing the FlacocoScanner main class. ```Java git clone https://github.com/eclipse/repairnator/ cd repairnator/src/repairnator-realtime mvn clean package -DskipTests java -cp target/repairnator-realtime--jar-with-dependencies.jar fr.inria.spirals.repairnator.realtime.FlacocoScanner ``` -------------------------------- ### Refactoring Magic Numbers to Named Constants in Java Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/sobo/templates/body/S109.md This code snippet contrasts the use of hardcoded 'magic numbers' with the best practice of defining them as named constants. The 'bad' example shows a literal number in a loop, while the 'good' example replaces it with a descriptive 'final' constant, significantly improving code understanding and maintainability. ```Java public class Example{ /* Foo method */ public static void foo() { // '4' is a magic number 😱🪄 for(int i = 0; i < 4; i++){ ... } } } ``` ```Java public class Example { // in java, constants are written in UPPER_CASE public static final int NUMBER_OF_CYCLES = 4; /* Foo method */ public static void foo() { // ah, it's the number of cycles! for(int i = 0; i < NUMBER_OF_CYCLES ; i++){ ... } } ``` -------------------------------- ### Launch Repairnator Travis CI Scanner Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/README.md This snippet outlines the steps to set up and launch the Repairnator Travis CI scanner, which continuously pulls new build identifiers from Travis CI. Prerequisites include Java and Docker. The process involves cloning the repository and executing a shell script. ```Bash git clone https://github.com/eclipse/repairnator/ cd repairnator/src/scripts/ bash launch_rtscanner.sh ``` -------------------------------- ### Repairnator Launcher Command Line Options Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/main-classes.md This section provides a detailed reference for all command-line options available when running the Repairnator pipeline. It includes parameter names, their expected types, and a description of their purpose and default values. ```APIDOC Usage: java [option(s)] Options: --ghOauth Specify GitHub Token to use. (-b|--build) Specify the Travis build ID to use. --repairTools repairTools1,repairTools2,...,repairToolsN Specify one or several repair tools to use among: NopolAllTests,NPEFix,AssertFixer,AstorJGenProg,AstorJKali,NopolSingleTest,AstorJMut,NopolTestExclusionStrategy (default: NopolAllTests,NPEFix,AssertFixer,AstorJGenProg,AstorJKali,NopolSingleTest,AstorJMut,NopolTestExclusionStrategy). [-h|--help] [-d|--debug] [--runId ] Specify the run ID for this launch. [--bears] This mode allows to use Repairnator to analyze pairs of bugs and human-produced patches. [(-o|--output) ] Specify the path to output serialized files. [--dbhost ] Specify MongDB host. [--dbname ] Specify MongoDB DB name (default: repairnator). [--smtpServer ] Specify SMTP server to use for Email notification. [--notifyto notifyto1,notifyto2,...,notifytoN ] Specify email addresses to notify. [--pushurl ] Specify repository URL to push data on the format https://github.com/user/repo. [--githubUserName ] Specify the name of the user who commits (default: repairnator). [--githubUserEmail ] Specify the email of the user who commits (default: noreply@github.com). [--createPR] Activate the creation of a Pull Request in case of patch. [(-n|--nextBuild) ] Specify the next build ID to use (only in BEARS mode) - (default: -1). [--z3 ] Specify path to Z3 (default: ./z3_for_linux). [(-w|--workspace) ] Specify a path to be used by the pipeline at processing things like to clone the project of the build ID being processed (default: ./workspace). [--projectsToIgnore ] Specify the file containing a list of projects that the pipeline should deactivate serialization when processing builds from (default: ./projects_to_ignore.txt). ``` -------------------------------- ### API Endpoint: Get Total Scanners Count Source: https://github.com/eclipse-repairnator/repairnator/blob/master/website/repairnator-mongo-rest-api/README.md Retrieves the total number of entries in the 'scanner' collection. ```APIDOC GET /scanners/count Description: Returns the total number of data entries in the 'scanner' collection. ``` ```json 4008 ``` -------------------------------- ### BibTeX entry for SOBO: A Feedback Bot Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/README.md This BibTeX entry provides the bibliographic details for the academic paper 'SOBO: A Feedback Bot to Nudge Code Quality in Programming Courses', published in IEEE Software in 2023. ```bibtex @article{2303.07187, title = {SOBO: A Feedback Bot to Nudge Code Quality in Programming Courses}, journal = {IEEE Software}, year = {2023}, doi = {10.1109/ms.2023.3298729}, author = {Sofia Bobadilla and Richard Glassey and Alexandre Bergel and Martin Monperrus}, url = {http://arxiv.org/pdf/2303.07187}, } ``` -------------------------------- ### BibTeX Citation for SOBO Feedback Bot Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/sobo/README.md BibTeX entry for the academic paper describing SOBO: A Feedback Bot to Nudge Code Quality in Programming Courses, published in IEEE Software, 2023. ```BibTeX @article{2303.07187, title = {SOBO: A Feedback Bot to Nudge Code Quality in Programming Courses}, journal = {IEEE Software}, year = {2023}, doi = {10.1109/ms.2023.3298729}, author = {Sofia Bobadilla and Richard Glassey and Alexandre Bergel and Martin Monperrus}, url = {http://arxiv.org/pdf/2303.07187}, } ``` -------------------------------- ### API Endpoint: Get Last 50 Patches Data Source: https://github.com/eclipse-repairnator/repairnator/blob/master/website/repairnator-mongo-rest-api/README.md Retrieves the 50 most recent entries from the 'patches' collection. ```APIDOC GET /patches/ Description: Returns the 50 most recent data entries from the 'patches' collection. ``` -------------------------------- ### Realtime Scanner (RTLauncher) Command-Line Usage Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/main-classes.md This section details the command-line options for the `RTLauncher` utility, which is the Realtime Scanner component of Repairnator. It allows users to configure GitHub authentication, specify repair tools, manage Docker images and output, set up logging, configure MongoDB, enable email notifications, control Docker container deletion, and define execution parameters like thread count, push URL, and build monitoring. ```bash Usage: java [option(s)] Options: --ghOauth Specify GitHub Token to use. --repairTools Specify one or several repair tools to use separated by commas (available tools might depend of your Docker image). (-o|--output) Specify where to put serialized files from dockerpool. (-n|--name) Specify the Docker image name to use. (-l|--logDirectory) Specify where to put logs and serialized files created by Docker machines. [-h|--help] [-d|--debug] [--runId ] Specify the run ID for this launch. [--dbhost ] Specify MongoDB host. [--dbname ] Specify MongoDB DB name (default: repairnator). [--notifyEndProcess] Activate the notification when the process ends. [--smtpServer ] Specify SMTP server to use for Email notification. [--notifyto notifyto1,notifyto2,...,notifytoN ] Specify email addresses to notify. [--skipDelete] Skip the deletion of Docker container. [--createOutputDir] Create a specific directory for output. [(-t|--threads) ] Specify the number of threads to run in parallel (default: 2). [--pushurl ] Specify repository URL to push data on the format https://github.com/user/repo. [--githubUserName ] Specify the name of the user who commits (default: repairnator). [--githubUserEmail ] Specify the email of the user who commits (default: noreply@github.com). [(-w|--whitelist) ] Specify the path of whitelisted repository. [(-b|--blacklist) ] Specify the path of blacklisted repository. [--jobsleeptime ] Specify the sleep time between two requests to Travis Job endpoint (in seconds) - (default: 60). [--buildsleeptime ] Specify the sleep time between two refresh of build statuses (in seconds) - (default: 10). [--maxinspectedbuilds ] Specify the maximum number of watched builds (default: 100). [--duration ] Duration of the execution. If it is not given, the execution never stops. This argument should be given on the ISO-8601 duration format: PWdTXhYmZs where W, X, Y, Z respectively represents number of Days, Hours, Minutes and Seconds. T is mandatory before the number of hours and P is always mandatory. [--createPR] Activate the creation of a Pull Request in case of patch. ``` -------------------------------- ### API Endpoint: Get Last 50 Real-time Scanners Data Source: https://github.com/eclipse-repairnator/repairnator/blob/master/website/repairnator-mongo-rest-api/README.md Retrieves the 50 most recent entries from the 'rtscanners' collection. ```APIDOC GET /rtScanners/ Description: Returns the 50 most recent data entries from the 'rtscanners' collection. ``` -------------------------------- ### Launch Maven release:perform command Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/release.md After preparing the release, execute the Maven `release:perform` command to deploy the jars. The `-DignoreSnapshots` flag should also be used here to handle snapshot dependencies. ```bash mvn release:perform -DignoreSnapshots ``` -------------------------------- ### Launch Maven release:prepare command Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/release.md Navigate to the repairnator directory and execute the Maven `release:prepare` command. The `-DignoreSnapshots` flag is crucial to bypass snapshot dependencies. This step prepares the release and may prompt for a password. ```bash cd repairnator mvn release:prepare -DignoreSnapshots ``` -------------------------------- ### Launch Repairnator on a GitHub Repository Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/main-classes.md This command demonstrates how to run Repairnator on a specified GitHub repository. It requires setting up Maven, a GitHub token, and the Java tools.jar, then executes the Repairnator pipeline in GIT_REPOSITORY mode with a target repository URL. ```bash export M2_HOME=/usr/share/maven export GITHUB_TOKEN=foobar # your Token export TOOLS_JAR=/usr/lib/jvm/default-java/lib/tools.jar java -cp $TOOLS_JAR:target/repairnator-pipeline-3.3-SNAPSHOT-jar-with-dependencies.jar fr.inria.spirals.repairnator.pipeline.Launcher --ghOauth $GITHUB_TOKEN --launcherMode GIT_REPOSITORY --gitrepourl https://github.com/repairnator/failingProject ``` -------------------------------- ### API Endpoint: Get Scanners Data for Last Month Source: https://github.com/eclipse-repairnator/repairnator/blob/master/website/repairnator-mongo-rest-api/README.md Retrieves scanner data recorded only for the last month. Returns an empty array if no data is available for the period. ```APIDOC GET /scanners/monthData Description: Returns scanner data for the last month. Returns an empty array if no data is found. ``` -------------------------------- ### Fetch and Display Repairnator Build Data with jQuery Source: https://github.com/eclipse-repairnator/repairnator/blob/master/website/repairnator-site/website/all-data.html This JavaScript snippet uses jQuery's `$.get` method to fetch build data from the Repairnator API. It then iterates over the received data to dynamically create and populate an HTML table, applying styling based on build status and converting URLs into clickable links. ```JavaScript $.get('https://repairnator.lille.inria.fr/repairnator-mongo-api/inspectors/', function (datas) { var htmlElement = $('#tablerealtime'); var fieldNames = [ {id:'buildFinishedDateStr', readable: 'Original date'}, {id: 'buildReproductionDateStr', readable: 'Date of the reproduction'}, {id: 'buildId', readable: 'Build ID'}, {id: 'repositoryName', readable: 'Github Repository'}, {id: 'status', readable: 'Status'}, {id: 'prNumber', readable: 'Pull Request ID'}, {id: 'travisURL', readable: 'URL of Travis build'}, {id: 'typeOfFailures', readable: 'Type of failures'}, {id: 'branchURL', readable: 'URL of the branch'} ]; var headersDisplayed = false; datas.forEach(function (data) { var row = $(''); htmlElement.append(row); if (!headersDisplayed) { fieldNames.forEach(function (fieldName) { var th = $(''); th.text(fieldName.readable); row.append(th); }); row = $(''); htmlElement.append(row); headersDisplayed = true; } fieldNames.forEach(function (column) { var fieldName = column.id; var td = $(''); var dataValue = data[fieldName]; if (fieldName == 'status') { if (data[fieldName] == 'PATCHED') { row.addClass('success'); } else if (data[fieldName] == 'test failure' || data[fieldName] == 'test errors') { row.addClass('warning'); } } if (fieldName == 'prNumber') { if (dataValue != 0) { dataValue = ''+dataValue+''; } } if (fieldName == 'typeOfFailures' && dataValue != null) { dataValue = dataValue.split(',').join(' '); } if (fieldName == 'travisURL') { dataValue = ''+dataValue+''; } if (fieldName == 'branchURL') { if (dataValue != undefined && dataValue != null) { dataValue = 'Go to branch'; } else { dataValue = 'N/A'; } } td.html(dataValue); row.append(td); }); }); }); ``` -------------------------------- ### API Endpoint: Get Specific Patch Entry by ID Source: https://github.com/eclipse-repairnator/repairnator/blob/master/website/repairnator-mongo-rest-api/README.md Retrieves a single patch entry using its unique `_id`. The `patchId` parameter must be a valid object ID. ```APIDOC GET /patches/:patchId Description: Returns a specific patch entry by its '_id'. Parameter: patchId (string) - The '_id' of the patch object. ``` ```json { "_id":"5c00338dcff47e0013e55010", "dateStr":"2018-11-29T19:44:29.144Z", "buildId":461420103, "diff":"...", "filepath":"/root/workspace/Twasi/twasi-core/461420103/src/main/java/net/twasi/core/database/models/User.java" } ``` -------------------------------- ### Run check_branches_test.sh script Source: https://github.com/eclipse-repairnator/repairnator/blob/master/src/docker-images/checkbranches-dockerimage/README.md This snippet shows the command to execute the `check_branches_test.sh` script, which contains the tests for `check_branches.sh`. ```bash $ ./check_branches_test.sh ``` -------------------------------- ### Repairnator Bot Command Reference Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/sobo/templates/help.md Documentation for the interactive commands available to users for controlling the Repairnator bot's behavior and querying repository data. ```APIDOC Bot Commands: \help: Get more information about usage. \go: Restart automatic feedback messages on your repository. \stop: Stop automatic feedback messages on your repository (can be changed in the future). \commit commitID: Description: Receive information about a specific commit on your repository. Parameters: commitID: The ID of the commit to query. \rule SonarRule: Description: Get the violations of a specific SonarQube rule on your repository's latest version. Parameters: SonarRule: Options include S109, S1481, S155. ``` -------------------------------- ### API Endpoint: Get Specific Scanner Entry by ID Source: https://github.com/eclipse-repairnator/repairnator/blob/master/website/repairnator-mongo-rest-api/README.md Retrieves a single scanner entry using its unique `_id`. The `scannerId` parameter must be a valid object ID. ```APIDOC GET /scanners/:scannerId Description: Returns a specific scanner entry by its '_id'. Parameter: scannerId (string) - The '_id' of the scanner object. ``` ```json { "_id": "5a5f3ccf7bb0706d6090d76f", "hostname": "spirals-librepair", "dateBeginStr": "17/01/18 13:01", "dateBegin": "2018-01-17T13:01:55.625Z", "dateLimitStr": "17/01/18 12:01", "dateLimit": "2018-01-17T12:01:55.623Z", "dayLimit": "17/01/2018", "totalRepoNumber": 281, "totalRepoUsingTravis": 276, "totalScannedBuilds": 35, "totalJavaBuilds": 33, "totalJavaPassingBuilds": 18, "totalJavaFailingBuilds": 5, "totalJavaFailingBuildsWithFailingTests": 4, "totalPRBuilds": 16, "duration": "0:6:52", "runId": "b4610a57-1ed2-4204-a6a1-114d6e2bb603" } ``` -------------------------------- ### API Endpoint: Get Scanners Data for Last N Weeks Source: https://github.com/eclipse-repairnator/repairnator/blob/master/website/repairnator-mongo-rest-api/README.md Retrieves scanner data for a specified number of recent weeks. Replace `:nbWeeks` with the desired number of weeks. ```APIDOC GET /scanners/weeksData/:nbWeeks Description: Returns scanner data for the last 'nbWeeks' weeks. ``` -------------------------------- ### Python Script for SOBO Execution Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/sobo/README.md Python script to configure environment variables and execute the SOBO Java application. It sets up database credentials, GitHub token, monitoring paths, scan parameters, and defines the execution flow for the bot. ```Python import subprocess import sys import os import multiprocessing as mp import time from pathlib import Path os.environ["launcherMode"] = "FEEDBACK" os.environ["dbUser"] = name.of-mongodb-user os.environ["pwd"] = password-for-the-mongo-db-user os.environ["GOAUTH"] = github-token-with-acess-to-students-repo os.environ["IP"] = ip-of-the-mongodb-server os.environ["REPOS_PATH"] = txt-of-repos-to-monitor // example "testing_repos_path.txt" os.environ["login"] = github-login //only necessary for Enterprise GitHub os.environ["SCAN_START_TIME"] = date-to-start // example "01/17/2023" os.environ["FETCH_MODE"] = "all" // defines if you want projects with failing tests os.environ["FEEDBACK_TOOL"] = "SoboBot" os.environ["SONAR_RULES"] = "S1481,S1155,S1213,S2119" os.environ["commandFrequency"]= "5000" // on miliseconds os.environ["collection"]="sobodb" // collection name of the database os.environ["command"]= "true" // if you want to run the command functionality or not date = time.localtime def process(): print(f"Working on: {date}") print(f"Working on: {os.path.dirname(os.path.realpath(__file__))}") os.system(f"java -jar repairnator1118.jar 1>> testCLlog.log 2>> testCLerr.err") def main(): process() if __name__ == "__main__": main() ``` -------------------------------- ### Java: Basic Random Number Generation Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/sobo/templates/body/S2119.md Demonstrates the fundamental steps to initialize a Random object and generate a single random integer using the nextInt() method in Java. ```Java Random rand = new Random(); int rValue = rand.nextInt(); ``` -------------------------------- ### JSON Message Format for Repairnator Queue Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/repairnator-kubernetes.md Example JSON format for messages sent to the Repairnator pipeline queue. This format allows specifying both the build ID and the Continuous Integration (CI) service. ```json {"buildId":"648902893","CI":"travis-ci.org"} ``` -------------------------------- ### Launch Repairnator pipeline for past builds Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/scripts.md This script is used to repair failing builds from the past. It can optionally take a path to a document containing a list of Travis Build IDs (one per line) as an argument. Without an argument, it combines scanning and docker pooling functionalities; with an argument, it behaves like `launch_dockerpool.sh`. ```bash ./launch_pipeline.sh [list_of_BuildIDs] ``` -------------------------------- ### API Endpoint: Get Specific Real-time Scanner Entry by ID Source: https://github.com/eclipse-repairnator/repairnator/blob/master/website/repairnator-mongo-rest-api/README.md Retrieves a single real-time scanner entry using its unique `_id`. The `rtScannerId` parameter must be a valid object ID. ```APIDOC GET /rtscanners/:rtScannerId Description: Returns a specific real-time scanner entry by its '_id'. Parameter: rtScannerId (string) - The '_id' of the rtScanner object. ``` ```json { "_id": "5bd450217b081636a53d45eb", "hostname": "repairnator-desktop", "runId": "cf4548a6-5551-462f-b63b-b3729a39473b", "dateWatched": "2018-10-27T13:46:41.456Z", "dateWatchedStr": "27/10/18 13:46", "dateBuildEnd": "2018-10-27T13:46:34.000Z", "dateBuildEndStr": "27/10/18 13:46", "repository": "Abrikosovp/junior", "buildId": 447059411, "status": "PASSED" } ``` -------------------------------- ### BibTeX entry for A Software Repair Bot based on Continual Learning Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/README.md This BibTeX entry provides the bibliographic details for the academic paper 'A Software Repair Bot based on Continual Learning', published in IEEE Software in 2021. ```bibtex @article{arXiv-2012.06824, title = {A Software Repair Bot based on Continual Learning}, author = {Benoit Baudry and Zimin Chen and Khashayar Etemadi and Han Fu and Davide Ginelli and Steve Kommrusch and Matias Martinez and Martin Monperrus and Javier Ron and He Ye and Zhongxing Yu}, journal = {IEEE Software}, year = {2021}, doi = {10.1109/ms.2021.3070743}, } ``` -------------------------------- ### BibTeX entry for Bears: An Extensible Java Bug Benchmark Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/README.md This BibTeX entry provides the bibliographic details for the academic paper 'Bears: An Extensible Java Bug Benchmark for Automatic Program Repair Studies', presented at SANER 2019. ```bibtex @inproceedings{madeiral:hal-01990052, title = {Bears: An Extensible Java Bug Benchmark for Automatic Program Repair Studies}, author = {Madeiral, Fernanda and Urli, Simon and Maia, Marcelo and Monperrus, Martin}, url = {https://arxiv.org/pdf/1901.06024}, booktitle = {{SANER 2019 - 26th IEEE International Conference on Software Analysis, Evolution and Reengineering}}, year = {2019}, doi = {10.1109/SANER.2019.8667991}, } ``` -------------------------------- ### BibTeX entry for How to Design a Program Repair Bot? Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/README.md This BibTeX entry provides the bibliographic details for the academic paper 'How to Design a Program Repair Bot? Insights from the Repairnator Project', presented at the 40th International Conference on Software Engineering in 2018. ```bibtex @inproceedings{urli:hal-01691496, title = {How to Design a Program Repair Bot? Insights from the Repairnator Project}, author = {Urli, Simon and Yu, Zhongxing and Seinturier, Lionel and Monperrus, Martin}, url = {https://hal.inria.fr/hal-01691496/file/SEIP_63_Camera-Ready-no-copyright.pdf}, booktitle = {{40th International Conference on Software Engineering, Track Software Engineering in Practice}}, pages = {95-104}, year = {2018}, doi = {10.1145/3183519.3183540}, } ``` -------------------------------- ### ROOT_BIN_DIR Configuration Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/repairnator-config.md Defines the main directory for Repairnator binaries. It will be created if it does not exist. This attribute is mandatory. ```APIDOC ROOT_BIN_DIR: Mandatory: Yes Description: Main directory for Repairnator binaries. Default Value: $HOME_REPAIR/bin/ ``` -------------------------------- ### Build Repairnator Docker image Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/release.md Build a Docker image for a specific Repairnator component, such as `pipeline-dockerimage`, tagging it with the appropriate version number. Replace `` with the actual version. ```bash docker build -t repairnator/pipeline: docker-images/pipeline-dockerimage ``` -------------------------------- ### Run Repairnator on the First Commit of a Git Repository Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/main-classes.md This example demonstrates how to configure Repairnator to analyze the oldest commit of a specified Git repository. By including the --gitrepofirstcommit flag, the tool overrides its default behavior of analyzing the latest commit on the master branch. ```bash export M2_HOME=/usr/share/maven export GITHUB_TOKEN=foobar # your Token export TOOLS_JAR=/usr/lib/jvm/default-java/lib/tools.jar java -cp $TOOLS_JAR:target/repairnator-pipeline-3.3-SNAPSHOT-jar-with-dependencies.jar fr.inria.spirals.repairnator.pipeline.Launcher --ghOauth $GITHUB_TOKEN --launcherMode GIT_REPOSITORY --gitrepourl --gitrepofirstcommit ``` -------------------------------- ### Java: Example of Using a Magic Number (Bad Practice) Source: https://github.com/eclipse-repairnator/repairnator/blob/master/src/repairnator-pipeline/src/main/java/fr/inria/spirals/repairnator/process/step/feedback/sobo/templates/body/S109.md This snippet demonstrates the use of a 'magic number' (the literal '4') directly within a for-loop condition. This practice is discouraged as the number's purpose is not immediately clear, making the code harder to understand and maintain. ```java public class Example{ /* Foo method */ public static void foo() { // '4' is a magic number 😱🪄 for(int i = 0; i < 4; i++){ ... } } } ``` -------------------------------- ### XPath queries for `patched_builds.py` output Source: https://github.com/eclipse-repairnator/repairnator/blob/master/doc/scripts.md The `patched_builds.py` script generates HTML files for each build, containing Travis build URLs, GitHub commit URLs, and patches with tool names. These XPath queries demonstrate how to extract specific data from these generated HTML files. ```APIDOC Select all patches created by : //[@title="tool"] ``` ```APIDOC Select all patches: //[@class="patch"] ``` ```APIDOC Select travis-url: //[@id="travis-url"] ``` ```APIDOC Select commit-url: //[@id="commit-url"] ``` ```APIDOC Get all links: //[@href] ``` ```APIDOC Get all toolnames (may have duplicates): //@title ```