Thank you for your interest in contributing to RepoSense!
- Setting up
- Prerequisites
- Setting up the project in your computer using IntelliJ
- Verifying the setup
- Configuring the Java coding style
- Configuring the JavaScript and CSS coding style
- Configuring Cypress for automated front-end testing
- (Optional) Using Vue.js devtools for frontend debugging on Chrome
- Before writing code
- Building and running RepoSense from code
- Architecture
- HTML Report
- JDK
1.8.0_60or later. You may download the JDK here. - git
2.14or later on the command line. You may download git here.
Type
git --versionon your OS terminal and ensure that you have the correct version of git.
- Fork this repo, and clone the fork to your computer.
- Open IntelliJ (if you are not in the welcome screen, click
File>Close Projectto close the existing project dialog first). - Set up the correct JDK version for Gradle.
- Click
Configure>Project Defaults>Project Structure. - Click
New…and find the directory of the JDK.
- Click
- Click
Import Project. - Locate the
build.gradlefile and select it. ClickOK. - Ensure that the selected version of
Gradle JVMmatches our prerequisite. - Click
OKto accept the all the other default settings.
- Ensure that Gradle builds without error by running the command
gradlew clean build, and ensure that it finishs with aBUILD SUCCESSFULmessage. - Run the tests to ensure that they all pass by running the command
gradlew test systemtest, and ensure that it finishs with aBUILD SUCCESSFULmessage.
Ensure that you are on the project root directory when using the
gradlewcommands.
This project follows oss-generic coding standards. IntelliJ’s default style is mostly compliant with our Java coding convention but it uses a different import order from ours. To rectify,
- Go to
File>Settings… (Windows/Linux), orIntelliJ IDEA>Preferences… (macOS). - Select
Editor>Code Style>Java. - Click on the
Importstab to set the order
Optionally, you can follow the Using Checkstyle document to configure Intellij to check style-compliance as you write code.
Our project follows the Airbnb Javascript Style Guide and OSS CSS Coding Standard, which is governed by the Eslint and Stylelint respectively. Their configuration files can be found at the root of the project. Please run a npm run lint from the project root directory and fix all of the lint errors before committing your code for final review.
Eslint, Stylelint and their accompanying modules can be installed through NPM, so do ensure that you got it installed if you are working on the report.
We use Cypress for automated end-to-end front-end testing.
- Create a new test file in
frontend/cypress/tests - At project root start Cypress Test Runner by running
gradlew cypress - On the top right hand corner, set
Chromeas the default browser - Under Integration Tests, click on the newly created test file to run it

Read Cypress's Documentation to familiarize yourself with its syntax and Cypress's debugging guide to tackle problems with your tests.
- At project root, run
gradlew frontendTest
If you encountered an invalid browser error, please ensure that you have
Chromeinstalled in the default installation directory. Otherwise, follow the instructions here to create symbolic links so Cypress can locateChromein your system.
- On your Chrome, visit the website of Vue.js devtools and add the extension.
- Go the detail page of this extension in Chrome's extension management panel and select
Allow access to file URLs. If you are unable to locate it, copy the link:chrome://extensions/?id=nhdogjmejiglipccpnnnanhbledajbpdand visit it on your Chrome. - Open any report generated by RepoSense.
- Press
F12or right click and chooseinspectat the report page. - Choose
Vueat the navigation bar.
- Debug using the tool.

See its Github page for more details.
- Do check out our process guide before submitting any PR with your changes.
- Execute the following command on the OS terminal inside the project directory.
Usage:gradlew run -Dargs="([--config CONFIG_FOLDER] | [--repos REPO_PATH_OR_URL...]) [--view [REPORT_FOLDER]] [--output OUTPUT_DIRECTORY] [--since DD/MM/YYYY] [--until DD/MM/YYYY] [--formats FORMAT...] [--ignore-standalone-config] [--timezone ZONE_ID[±hh[mm]]]"
Named Arguments:
--help, -h Show help message.
--version, -V Show the version of RepoSense.
--view [PATH], -v [PATH]
Starts a server to display the report in the
provided directory. If used as a flag (with no
argument), generates a report and automatically
displays the report.
--output PATH, -o PATH
The directory to output the report folder,
reposense-report. If not provided, the report
folder will be created in the current working
directory.
--since dd/MM/yyyy, -s dd/MM/yyyy
The date to start filtering.
--until dd/MM/yyyy, -u dd/MM/yyyy
The date to stop filtering.
--formats [FORMAT [FORMAT ...]], -f [FORMAT [FORMAT ...]]
The alphanumeric file formats to process.
If not provided, all file formats will be
used.
Please refer to userguide for more information.
--ignore-standalone-config, -i
A flag to ignore the standalone config file in
the repo.
--timezone ZONE_ID[±hh[mm]], -t ZONE_ID[±hh[mm]]
The timezone to use for the generated report.
One kind of valid timezones is relative to UTC.
E.g. UTC, UTC+08, UTC-1030.
If not provided, system default timezone will be used.
--config PATH, -c PATH
The directory containing the config files. If not
provided, the config files will be obtained from
the current working directory.
--repo LOCATION [LOCATION ...], --repos LOCATION [LOCATION ...], -r LOCATION [LOCATION ...]
The GitHub URL or disk locations to clone repository.
Sample usage to generate the report with no specify arguments: (find and use config files in current working directory)
gradlew run
Sample usage to generate the report with config files and automatically open the report:
gradlew run -Dargs="--config ./configs/ --output output_path/ --since 21/10/2017 --until 21/11/2017 --formats java adoc js --view"
Sample usage to generate the report with config files and choose the timezone used to be UTC+8:
gradlew run -Dargs="--config ./configs/ --output output_path/ --timezone UTC+08"
Sample usage to generate the report with repository locations and automatically open the report:
gradlew run -Dargs="--repos https://github.com/reposense/RepoSense.git https://github.com/se-edu/collate.git --output output_path/ --since 21/10/2017 --until 21/11/2017 --formats java adoc js --view"
Sample usage to generate the report with repository locations but ignore the standalone config file:
gradlew run -Dargs="--repos https://github.com/reposense/RepoSense.git https://github.com/se-edu/collate.git --ignore-standalone-config"
Sample usage to view the report:
gradlew run -Dargs="--view output_path/reposense-report"
Sample usage to generate the report with config files using the alias of argument:
gradlew run -Dargs="-c ./configs/ -o output_path/ -s 21/10/2017 -u 21/11/2017 -f java adoc js"
-Dargs="..." uses the same argument format as mentioned above.
Figure 1. Overall architecture of RepoSense
Parser contains three components:
ArgsParser: Parses the user-supplied command line arguments into aCliArgumentsobject.CsvParser: Abstract generic class for CSV parsing functionality. The following three classes extendCsvParser.AuthorConfigCsvParser: Parses theauthor-config.csvconfig file into a list ofAuthorConfigurationfor each repository to analyze.GroupConfigCsvParserParses thegroup-config.csvconfig file into a list ofGroupConfigurationfor each repository to analyze.RepoConfigCsvParser: Parses therepo-config.csvconfig file into a list ofRepoConfigurationfor each repository to analyze.
JsonParser: Abstract generic class for JSON parsing functionality. The following class extendsJsonParserclass:StandaloneConfigJsonParser: Parses the_reposense/config.jsonconfig file into aStandaloneConfig.
Git package contains the wrapper classes for respective git commands.
GitBlame: Wrapper class forgit blamefunctionality. Traces the revision and author last modified each line of a file.GitBranch: Wrapper class forgit branchfunctionality. Gets the name of the working branch of the target repo.GitCheckout: Wrapper class forgit checkoutfunctionality. Checks out the repository by branch name or commit hash.GitClone: Wrapper class forgit clonefunctionality. Clones the repository from GitHub into a temporary folder in order to run the analysis.GitDiff: Wrapper class forgit difffunctionality. Obtains the changes between commits.GitLog: Wrapper class forgit logfunctionality. Obtains the commit logs and the authors' info.GitLsTree: Wrapper class forgit ls-treefunctionality. Ensures that the tracked files do not contain any paths with illegal characters for Windows users.GitRevList: Wrapper class forgit rev-listfunctionality. Retrieves the commit objects in reverse chronological order.GitRevParse: Wrapper class forgit rev-parsefunctionality. Ensures that the branch of the repo is to be analyzed exists.GitShortlog: Wrapper class forgit shortlogfunctionality. Obtains the list of authors who have contributed to the target repo.GitUtil: Contains helper functions used by the other Git classes above.
CommitsReporter is responsible for analyzing the commit history and generating a CommitContributionSummary for each repository. CommitContributionSummary contains information such as each author's daily and weekly contribution and the variance of their contribution. CommitsReporter,
- uses
CommitInfoExtractorto run thegit logcommand, which generates the statistics of each commit made within date range. - generates a
CommitInfofor each commit, which contains theinfoLineandstatLine. - uses
CommitInfoAnalyzerto extract the relevant data fromCommitInfointo aCommitResult, such as the number of line insertions and deletions in the commit and the author of the commit. - uses
CommitResultAggregatorto aggregate allCommitResultinto aCommitContributionSummary.
AuthorshipReporter is responsible for analyzing the white listed files, traces the original author for each line of text/code, and generating an AuthorshipSummary for each repository. AuthorshipSummary contains the analysis results of the white listed files and the amount of line contributions each author made. AuthorshipReporter,
- uses
FileInfoExtractorto traverse the repository to find all relevant files. - generates a
FileInfofor each relevant file, which contains the path to the file and a list ofLineInforepresenting each line of the file. - uses
FileInfoAnalyzerto analyze each file, usinggit blameor annotations, and finds theAuthorfor eachLineInfo. - generates a
FileResultfor each file, which consolidates the authorship results into a Map of each author's line contribution to the file. - uses
FileResultAggregatorto aggregate allFileResultinto anAuthorshipSummary.
- uses
GitCloneAPI to clone the repository from GitHub. - copies the template files into the designated output directory.
- uses
CommitReporterandAuthorshipReporterto produce the commit and authorship summary respectively. - generates the
JSONfiles needed to generate theHTMLreport.
System contains the classes that interact with the Operating System and external processes.
CommandRunnercreates processes that executes commands on the terminal. It consists of many git commands.LogsManageruses thejava.util.loggingpackage for logging. TheLogsManagerclass is used to manage the logging levels and logging destinations. Log messages are output through:Consoleand to a.logfile.ReportServerstarts a server to display the report on the browser. It depends on thenet.freeutils.httpserverpackage.
Model holds the data structures that are commonly used by the different aspects of RepoSense.
Authorstores theGitHub IDof an author. Any contributions or commits made by the author, using his/herGitHub IDor aliases, will be attributed to the sameAuthorobject. It is used byAuthorshipReporterandCommitsReporterto attribute the commit and file contributions to the respective authors.CliArgumentsstores the parsed command line arguments supplied by the user. It contains the configuration settings such as the CSV config file to read from, the directory to output the report to, and date range of commits to analyze. These configuration settings are passed intoRepoConfiguration.FileTypeManagerstores the file format to be analyzed and the custom groups specified by the user for any repository.RepoConfigurationstores the configuration information from the CSV config file for a single repository, which are the repository's orgarization, name, branch, list of authors to analyse, date range to analyze commits and files fromCliArguments. These configuration information are used by:GitCloneto determine the location to clone the repository from and which branch to check out to.AuthorshipReporterandCommitsReporterto determine the range of commits and files to analyze.ReportGeneratorto determine the directory to output the report.
The source files for the report is located in frontend/src and is built by spuild before being packaged into the JAR file to be extracted as part of the report.
The main HTML file is generated from frontend/src/index.pug.
Vue (pronounced /vjuː/, like view) is a progressive framework for building user interfaces. It is heavily utilized in the report to dynamically update the information in the various views. (Style guide available here, Developer tool available here). Vue lifecycle hooks are the defined methods which gets executed in a certain stage of the Vue object lifespan. The following is the Vue lifecycle diagram taken from here indicating the hook sequence:

The following is a snapshot of the report:

The main Vue object (window.app) is responsible for the loading of the report (through summary.json). Its repos attribute is tied to the global window.REPOS, and is passed into the various other modules when the information is needed.
window.app is broken down into two main parts
- the summary view
- and the tabbed interface
The summary view acts as the main report which shows the various calculations.
The tabbed interface is responsible for loading various modules such as authorship and zoom to display additional information.
- main.js - main controller that pushes content into different modules
- api.js - loading and parsing of the report content
- v_summary.js - module that supports the summary view
- v_authorship.js - module that supports the authorship tab view
- v_zoom.js - module that supports the zoom tab view
- v_ramp.js - module that supports the ramp chart view
- v_segment.js - module that supports the code segment view
- summary.json - a list of all the repositories and their respective details
- projName/commits.json - contains information of the users' commits information (e.g. line deletion, insertion, etc), grouped by date
- projName/authorship.json - contains information from git blame, detailing the author of each line for all the processed files
Main (main.js)
This contains the logic for main VueJS object, window.app, which is responsible for passing the necessary data into the relevant modules to be loaded.
v_summary, v_authorship, v_zoom, v_segment and v_ramp are components which will be embedded into report and will render the corresponding content based on the data passed into it from the main window.app.
The main Vue object depends on the summary.json data to determine the right commits.json files to load into memory. This is handled by api.js which loads the relevant file information from the network files if it is available, otherwise a report archive, archive.zip, have to be used.
Once the relevant commit.json files are loaded, all the repo information will be passed into v_summary to be loaded in the summary view as the relevant ramp charts.
Most activity or actions should happen within the module itself, but in the case where there is a need to spawn or alter the view of another module, an event is emitted from the first module to the main Vue object (window.app), which then handles the data received and passes it along to the relevant modules.
Other than the global main Vue object, another global variable we have is the window.hashParams. This object is reponsible for generating the relevant permalink for a specific view of the summary module for the report.
Data loader (api.js)
This is the module that is in charge of loading and parsing the data files generated as part of the report.
Due to security design, most modern browsers (e.g. Chrome) do not allow web pages to obtain local files using the directory alone. As such, a ZIP archive of the report information will be produced alongside the report generation.
This archive will be used in place of the network files to load information into the report, in the case when the network files are unavailable.
The API module will be handling all request for all the JSON data files. If the network file is not available, the files will be obtained from the zip archive provided.
After the JSON files are loaded from their respective sources, the data will be parsed as objects and included inside the global storage object, window.REPOS, in the right format.
For the basic skeleton of window.REPOS, refer to the generated summary.json file in the report for more details.
Summary View (v_summary.js)
The v_summary module is in charge of loading the ramp charts from the corresponding commits.json.
The summary module is activated after the information is loaded from the main Vue.JS object. At creation, the repo attribute is populated with the window.REPOS object, which contains information loaded from summary.json.
The commits information is retrieved from the corresponding project folders for each repository. These information will be filtered and sorted before passed into the template to be displayed as ramp charts.
Authorship View (v_authorship.js)
The authorship module retrieves the relevant information from the corresponding authorship.json file if it is not yet loaded. If it has been loaded, the data will be written into window.REPOS and be read from there instead.
The files will be filtered, picking only files the selected author has written in. The lines are then split into chunks of "touched" and "untouched" code segments to be displayed in the tab view which will be popped up on the right side of the screen.
Zoom View (v_zoom.js)
The v_zoom module is in charge of filtering and displaying the commits from selected sub-range of a ramp chart.
Ramp View (v_ramp.js)
The v_ramp module is responsible for receiving the relevant information from v_summary and generating ramp charts that contain ramp slices.
For ramps between the date ranges, the slices will be selected and it will be pre and post padded with empty slices to align the ramp slice between the sinceDate and untilDate. The ramps will then be rendered with the slices in the right position.
Segment View (v_segment.js)
The v-segment module is used as a component in v_authorship. It separates the code in terms of "touched" and "untouched" segments and only loads each "untouched" segment when it is toggled.



