Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2161] One-Stop Config File for Code Portfolio #2192

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ dependencies {
implementation group: 'org.apache.ant', name: 'ant', version: '1.10.12'
implementation group: 'org.apache.commons', name: 'commons-csv', version: '1.9.0'
implementation group: 'org.fusesource.jansi', name: 'jansi', version: '2.4.0'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.17.0'
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.17.0'

testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: jUnitVersion
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: jUnitVersion
Expand Down
43 changes: 43 additions & 0 deletions config/report-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
title: RepoSense Report
ckcherry23 marked this conversation as resolved.
Show resolved Hide resolved
group-details:
- repo: https://github.com/user/repo/tree/fake-branch
ckcherry23 marked this conversation as resolved.
Show resolved Hide resolved
groups:
asdfghjkxd marked this conversation as resolved.
Show resolved Hide resolved
- group-name: code
globs:
- "**.java"
- group-name: tests
globs:
- "src/test**"
- group-name: docs
globs:
- "docs**"
- "**.adoc"
- "**.md"
repos:
- repo: https://github.com/user/repo/tree/fake-branch
ckcherry23 marked this conversation as resolved.
Show resolved Hide resolved
author-emails:
- john@john.com
- johny@mail.com
- j@domain.com
author-git-host-id: johnDoe
author-display-name: John Doe
author-git-author-name: my home PC
branches:
- branch: main
file-formats:
- override:java
- md
- fxml
ignore-glob-list:
- "docs**"
ignore-standalone-config: true
ignore-commits-list:
- 2fb6b9b2dd9fa40bf0f9815da2cb0ae8731436c7
- c5a6dc774e22099cd9ddeb0faff1e75f9cf4f151
- cd7f610e0becbdf331d5231887d8010a689f87c7
- 768015345e70f06add2a8b7d1f901dc07bf70582
ignore-authors-list:
- author1
- author2
is-shallow-cloning: true
is-find-previous-authors: false
16 changes: 13 additions & 3 deletions docs/ug/configFiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,22 @@ e.g.: `example.java` in `example-repo` can either be in the `test` group or the

<!-- ==================================================================================================== -->

## `report-config.json`
## `report-config.yaml`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also update the --config flag under 'CLI syntax reference' to include report-config.yaml instead of json? https://docs-2192-pr-reposense-reposense.surge.sh/ug/cli.html#config-c

Let's also update the 'Customize using CSV config files' heading on the 'Customizing Reports` page to include YAML or remove file types entirely. https://docs-2192-pr-reposense-reposense.surge.sh/ug/customizingReports.html#customize-using-csv-config-files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do!


You can optionally use `report-config.json` to customize report generation by providing the following information. ([example](report-config.json))
You can also optionally use a `report-config.yaml` file to quickly define the repository information for the repositories you are interested in tracking and generate your very own code portfolio.

View this [example](report-config.yaml) for a better understanding of what repository information is required.

**Fields to provide**:
ckcherry23 marked this conversation as resolved.
Show resolved Hide resolved
* `title`: Title of the generated report, which is also the title of the deployed dashboard. Default: "RepoSense Report"
* `repoUrl`: The URL to your repository of interest
* `reportTitle`: Title of the generated report, which is also the title of the deployed dashboard. Default: "RepoSense Report"
* `authorDisplayName`: Name of the author to track in the repository.
* `authorGithubId`: The GitHub username of the author to track in the repository.
ckcherry23 marked this conversation as resolved.
Show resolved Hide resolved
* `branches`: A list of branches with their associated blurbs.
* `name`: Name of the branch to track
* `blurb`: Blurb to include with the branch
* `startDate`: The start date of analysis for RepoSense. Default: "2020-01-01"
* `endDate`: The end date of analysis for RepoSense. Default: "9999-12-32"

<!-- ==================================================================================================== -->

Expand Down
3 changes: 0 additions & 3 deletions docs/ug/report-config.json

This file was deleted.

43 changes: 43 additions & 0 deletions docs/ug/report-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
title: RepoSense Report
group-details:
- repo: https://github.com/user/repo/tree/fake-branch
groups:
- group-name: code
globs:
- "**.java"
- group-name: tests
globs:
- "src/test**"
- group-name: docs
globs:
- "docs**"
- "**.adoc"
- "**.md"
repos:
- repo: https://github.com/user/repo/tree/fake-branch
author-emails:
- john@john.com
- johny@mail.com
- j@domain.com
author-git-host-id: johnDoe
author-display-name: John Doe
author-git-author-name: my home PC
branches:
- branch: main
file-formats:
- override:java
- md
- fxml
ignore-glob-list:
- "docs**"
ignore-standalone-config: true
ignore-commits-list:
- 2fb6b9b2dd9fa40bf0f9815da2cb0ae8731436c7
- c5a6dc774e22099cd9ddeb0faff1e75f9cf4f151
- cd7f610e0becbdf331d5231887d8010a689f87c7
- 768015345e70f06add2a8b7d1f901dc07bf70582
ignore-authors-list:
- author1
- author2
is-shallow-cloning: true
is-find-previous-authors: false
3 changes: 0 additions & 3 deletions frontend/cypress/config/report-config.json

This file was deleted.

1 change: 1 addition & 0 deletions frontend/cypress/config/report-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title: RepoSense Test Report
2 changes: 1 addition & 1 deletion src/main/java/reposense/RepoSense.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import reposense.git.GitConfig;
import reposense.model.CliArguments;
import reposense.model.RepoConfiguration;
import reposense.model.ReportConfiguration;
import reposense.model.RunConfigurationDecider;
import reposense.model.reportconfig.ReportConfiguration;
import reposense.parser.ArgsParser;
import reposense.parser.exceptions.InvalidCsvException;
import reposense.parser.exceptions.InvalidHeaderException;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/reposense/model/CliArguments.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
import java.util.List;
import java.util.Objects;

import reposense.model.reportconfig.ReportConfiguration;
import reposense.parser.ArgsParser;
import reposense.parser.AuthorConfigCsvParser;
import reposense.parser.GroupConfigCsvParser;
import reposense.parser.RepoConfigCsvParser;
import reposense.parser.ReportConfigJsonParser;
import reposense.parser.ReportConfigYamlParser;

/**
* Represents command line arguments user supplied when running the program.
Expand Down Expand Up @@ -453,7 +454,7 @@ public Builder configFolderPath(Path configFolderPath) {
this.cliArguments.groupConfigFilePath = configFolderPath.resolve(
GroupConfigCsvParser.GROUP_CONFIG_FILENAME);
this.cliArguments.reportConfigFilePath = configFolderPath.resolve(
ReportConfigJsonParser.REPORT_CONFIG_FILENAME);
ReportConfigYamlParser.REPORT_CONFIG_FILENAME);
return this;
}

Expand Down
13 changes: 0 additions & 13 deletions src/main/java/reposense/model/ReportConfiguration.java

This file was deleted.

121 changes: 121 additions & 0 deletions src/main/java/reposense/model/reportconfig/ReportBranchData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package reposense.model.reportconfig;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Represents a single entry of a branch in the YAML config file.
*/
public class ReportBranchData {
public static final String DEFAULT_BRANCH = "main";
public static final List<String> DEFAULT_FILE_FORMATS = List.of(
"override:java", "md", "fxml"
);
public static final List<String> DEFAULT_IGNORE_GLOB_LIST = List.of(
"docs**"
);
public static final List<String> DEFAULT_IGNORE_COMMITS_LIST = List.of(
"2fb6b9b2dd9fa40bf0f9815da2cb0ae8731436c7",
"c5a6dc774e22099cd9ddeb0faff1e75f9cf4f151",
"cd7f610e0becbdf331d5231887d8010a689f87c7",
"768015345e70f06add2a8b7d1f901dc07bf70582"
);
public static final List<String> DEFAULT_IGNORE_AUTHORS_LIST = List.of(
"author1",
"author2"
);
public static final boolean DEFAULT_IS_FIND_PREVIOUS_AUTHOR = false;
public static final boolean DEFAULT_IS_SHALLOW_CLONING = true;
public static final boolean DEFAULT_IS_IGNORE_STANDALONE_CONFIG = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we need these hardcoded default values here? Check for this in the other files inside reportconfig/ too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe they are present for testing purposes (creating default instances), but I will have to check before reverting back to you!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they're just for tests, could we move them into the test files like we do for test defaults for the other classes? It doesn't seem like these values are useful defaults outside of the tests.


public static final ReportBranchData DEFAULT_INSTANCE = new ReportBranchData();

static {
DEFAULT_INSTANCE.branch = ReportBranchData.DEFAULT_BRANCH;
DEFAULT_INSTANCE.fileFormats = ReportBranchData.DEFAULT_FILE_FORMATS;
DEFAULT_INSTANCE.ignoreGlobList = ReportBranchData.DEFAULT_IGNORE_GLOB_LIST;
DEFAULT_INSTANCE.ignoreCommitList = ReportBranchData.DEFAULT_IGNORE_COMMITS_LIST;
DEFAULT_INSTANCE.ignoreAuthorList = ReportBranchData.DEFAULT_IGNORE_AUTHORS_LIST;
DEFAULT_INSTANCE.isFindPreviousAuthor = ReportBranchData.DEFAULT_IS_FIND_PREVIOUS_AUTHOR;
DEFAULT_INSTANCE.isShallowCloning = ReportBranchData.DEFAULT_IS_SHALLOW_CLONING;
DEFAULT_INSTANCE.isIgnoreStandaloneConfig = ReportBranchData.DEFAULT_IS_IGNORE_STANDALONE_CONFIG;
}

@JsonProperty("branch")
private String branch;

@JsonProperty("file-formats")
private List<String> fileFormats;

@JsonProperty("ignore-glob-list")
private List<String> ignoreGlobList;

@JsonProperty("ignore-standalone-config")
private Boolean isIgnoreStandaloneConfig;

@JsonProperty("ignore-commits-list")
private List<String> ignoreCommitList;

@JsonProperty("ignore-authors-list")
private List<String> ignoreAuthorList;

@JsonProperty("is-shallow-cloning")
private Boolean isShallowCloning;

@JsonProperty("is-find-previous-authors")
private Boolean isFindPreviousAuthor;

public String getBranch() {
return branch == null ? DEFAULT_BRANCH : branch;
}

public List<String> getFileFormats() {
return fileFormats == null ? DEFAULT_FILE_FORMATS : fileFormats;
}

public List<String> getIgnoreGlobList() {
return ignoreGlobList == null ? DEFAULT_IGNORE_GLOB_LIST : fileFormats;
}

public boolean getIsIgnoreStandaloneConfig() {
return isIgnoreStandaloneConfig == null ? DEFAULT_IS_IGNORE_STANDALONE_CONFIG : isIgnoreStandaloneConfig;
}

public List<String> getIgnoreCommitList() {
return ignoreCommitList == null ? DEFAULT_IGNORE_COMMITS_LIST : ignoreCommitList;
}

public List<String> getIgnoreAuthorList() {
return ignoreAuthorList == null ? DEFAULT_IGNORE_AUTHORS_LIST : ignoreAuthorList;
}

public boolean getIsShallowCloning() {
return isShallowCloning == null ? DEFAULT_IS_SHALLOW_CLONING : isShallowCloning;
}

public boolean getIsFindPreviousAuthor() {
return isFindPreviousAuthor == null ? DEFAULT_IS_FIND_PREVIOUS_AUTHOR : isFindPreviousAuthor;
}

@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}

if (obj instanceof ReportBranchData) {
ReportBranchData rbd = (ReportBranchData) obj;
return this.getBranch().equals(rbd.getBranch())
&& this.getFileFormats().equals(rbd.getFileFormats())
&& this.getIgnoreGlobList().equals(rbd.getIgnoreGlobList())
&& this.getIsIgnoreStandaloneConfig() == rbd.getIsIgnoreStandaloneConfig()
&& this.getIgnoreCommitList().equals(rbd.getIgnoreCommitList())
&& this.getIgnoreAuthorList().equals(rbd.getIgnoreAuthorList())
&& this.getIsShallowCloning() == rbd.getIsShallowCloning()
&& this.getIsFindPreviousAuthor() == rbd.getIsFindPreviousAuthor();
}

return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package reposense.model.reportconfig;

import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Class that contains information on a report's configurations.
* This class is used mainly for quickly setting up one's personal code portfolio.
*/
public class ReportConfiguration {
public static final String DEFAULT_TITLE = "RepoSense Report";
public static final List<ReportGroupDetails> DEFAULT_REPORT_GROUP_DETAILS = new ArrayList<>();
public static final List<ReportRepoConfiguration> DEFAULT_REPORT_REPO_CONFIGS = new ArrayList<>();

static {
DEFAULT_REPORT_REPO_CONFIGS.add(ReportRepoConfiguration.DEFAULT_INSTANCE);
DEFAULT_REPORT_GROUP_DETAILS.add(ReportGroupDetails.DEFAULT_INSTANCE);
}

@JsonProperty("title")
private String title;

@JsonProperty("group-details")
private List<ReportGroupDetails> groupDetails;

@JsonProperty("repos")
private List<ReportRepoConfiguration> reportRepoConfigurations;

public String getTitle() {
return title == null ? DEFAULT_TITLE : title;
}

public List<ReportGroupDetails> getGroupDetails() {
return groupDetails == null ? DEFAULT_REPORT_GROUP_DETAILS : groupDetails;
}

public List<ReportRepoConfiguration> getReportRepoConfigurations() {
return reportRepoConfigurations == null ? DEFAULT_REPORT_REPO_CONFIGS : reportRepoConfigurations;
}

@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}

if (obj instanceof ReportConfiguration) {
ReportConfiguration rc = (ReportConfiguration) obj;
return rc.getTitle().equals(this.getTitle())
&& rc.getReportRepoConfigurations().equals(this.getReportRepoConfigurations());
}

return false;
}
}
Loading
Loading