diff --git a/build.gradle b/build.gradle index 789f245400..b5827976aa 100644 --- a/build.gradle +++ b/build.gradle @@ -196,7 +196,7 @@ def serveTestReportInBackground = tasks.register('serveTestReportInBackground', workingDir = 'build/serveTestReport' main = mainClassName classpath = sourceSets.main.runtimeClasspath - args = ['--config', './exampleconfig', '--since', 'd1', '--view'] + args = ['--config', './exampleconfig', '--since', 'd1', '--view', '-A'] String versionJvmArgs = '-Dversion=' + getRepoSenseVersion() jvmArgs = [ versionJvmArgs ] waitForPort = 9000 diff --git a/docs/ug/cli.md b/docs/ug/cli.md index db0cbe5243..550713969c 100644 --- a/docs/ug/cli.md +++ b/docs/ug/cli.md @@ -16,16 +16,36 @@ The command `java -jar RepoSense.jar` takes several flags. **Examples**: An example of a command using most parameters:
-`java -jar RepoSense.jar --repos https://github.com/reposense/RepoSense.git --output ./report_folder --since 31/1/2017 --until 31/12/2018 --formats java adoc xml --view --ignore-standalone-config --last-modified-date --timezone UTC+08 --find-previous-authors` +`java -jar RepoSense.jar --repos https://github.com/reposense/RepoSense.git --output ./report_folder --since 31/1/2017 --until 31/12/2018 --formats java adoc xml --view --ignore-standalone-config --last-modified-date --timezone UTC+08 --find-previous-authors --analyze-authorship --originality-threshold 0.66` Same command as above but using most parameters in alias format:
-`java -jar RepoSense.jar -r https://github.com/reposense/RepoSense.git -o ./report_folder -s 31/1/2017 -u 31/12/2018 -f java adoc xml -v -i -l -t UTC+08 -F` +`java -jar RepoSense.jar -r https://github.com/reposense/RepoSense.git -o ./report_folder -s 31/1/2017 -u 31/12/2018 -f java adoc xml -v -i -l -t UTC+08 -F -A -ot 0.66` The section below provides explanations for each of the flags. +### `--analyze-authorship`, `-A` + +**`--analyze-authorship`**: Performs further analysis to distinguish between partial and full credit attribution for +lines of code assigned to the author. + +* Default: this feature is turned ***off*** by default and the author will receive partial credits for all lines of + code, as the code lines are at least partial credit but may not qualify for full credit. +* Alias: `-A` (upper case) +* Example: `--analyze-authorship` or `-A` + + + +A darker background colour represents full credit, while a lighter background colour represents partial credit. + +If the code is attributed to a different author by the user via `@@author` tag, then the new author will be given +partial credit. + + + + ### `--assets`, `-a`
@@ -147,6 +167,26 @@ This flag overrides the `Ignore file size limit` field in the CSV config file. +### `--originality-threshold`, `-ot` + +**`--originality-threshold [VALUE]`**: Specifies the cut-off point for partial and full credit +in `--analyze-authorship`. Author will be given full credit if their contribution exceeds this threshold, else partial +credit is given. + +* Parameter: `VALUE` Optional. Acceptable range: [0.0, 1.0].
+ Default: `0.51` +* Alias: `-ot` +* Example: `--originality-threshold 0.66` or `-ot 0.66` + + + +* Requires `--analyze-authorship` flag. +* An author's contribution, or `originality score`, is calculated using Levenshtein Distance (Edit Distance) algorithm. + We compare the difference between current code line and its previous versions. + + + + ### `--output`, `-o` **`--output OUTPUT_DIRECTORY`**: Indicates where to save the report generated. diff --git a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js index 727478e8f0..79c3334528 100644 --- a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js +++ b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js @@ -38,7 +38,7 @@ describe('code highlighting works properly', () => { cy.get('.hljs-comment').contains('* Represents a Git Author.') .parent() // .line-content .parent() // .code - .should('have.css', 'background-color', 'rgb(230, 255, 237)'); // #e6ffed + .should('have.css', 'background-color', 'rgb(191, 246, 207)'); // #BFF6CF }); it('should highlight code when multiple authors are merged in a repo group', () => { @@ -62,13 +62,13 @@ describe('code highlighting works properly', () => { cy.get('.hljs-comment').contains('* MUI Colors module') // eugenepeh .parent() // .line-content .parent() // .code - .should('have.css', 'background-color', 'rgba(30, 144, 255, 0.19)') // #1e90ff, transparencyValue 30 + .should('have.css', 'background-color', 'rgba(30, 144, 255, 0.314)') // #1e90ff, transparencyValue 50 .then((firstAuthorColor) => { // eslint-disable-next-line quotes cy.get('.line-content').contains("'red': (") // jamessspanggg .parent() // .code - // #f08080, transparencyValue 30 - .should('have.css', 'background-color', 'rgba(240, 128, 128, 0.19)') + // #f08080, transparencyValue 50 + .should('have.css', 'background-color', 'rgba(240, 128, 128, 0.314)') .and('not.eq', firstAuthorColor); }); }); diff --git a/frontend/cypress/tests/codeView/codeView_creditBackgroundColour.cy.js b/frontend/cypress/tests/codeView/codeView_creditBackgroundColour.cy.js new file mode 100644 index 0000000000..684f977e59 --- /dev/null +++ b/frontend/cypress/tests/codeView/codeView_creditBackgroundColour.cy.js @@ -0,0 +1,55 @@ +describe('credit background colour', () => { + it('check if background colour match the credit information for Eugene', () => { + // open the code panel + cy.get('.icon-button.fa-code') + .should('exist') + .first() + .click(); + + // src/main/java/reposense/model/Author.java + // line 9: full credit - #BFF6CF + cy.get(':nth-child(1) > .file-content > .segment-collection > :nth-child(2) > .java > .code') + .should('have.css', 'background-color') + .and('eq', 'rgb(191, 246, 207)'); + + // src/main/java/reposense/model/Author.java + // line 15: partial credit - #E6FFED + cy.get(':nth-child(1) > .file-content > .segment-collection > :nth-child(4) > .java > .code') + .should('have.css', 'background-color') + .and('eq', 'rgb(230, 255, 237)'); + }); + + it('check if background colour match the credit information when group is merged', () => { + // check merge group checkbox + cy.get('#summary label.merge-group > input') + .should('be.visible') + .check() + .should('be.checked'); + + // open the code panel + cy.get('.icon-button.fa-code') + .should('exist') + .first() + .click(); + + // frontend/src/styles/_colors.scss + // line 35: full credit - #F0808050 + cy.get(':nth-child(7) > .scss > :nth-child(1)') + .should('have.css', 'background-color') + .and('eq', 'rgba(240, 128, 128, 0.314)'); + + // FileInfoExtractor.java is too far away to be loaded, use filter to go to it directly + cy.get('#search') + .click() + .type('FileInfoExtractor.java'); + + cy.get('#submit-button') + .click(); + + // src/main/java/reposense/authorship/FileInfoExtractor.java + // line 23: partial credit - #1E90FF20 + cy.get(':nth-child(10) > .java > :nth-child(1)') + .should('have.css', 'background-color') + .and('eq', 'rgba(30, 144, 255, 0.125)'); + }); +}); diff --git a/frontend/src/components/c-segment.vue b/frontend/src/components/c-segment.vue index 0fcec1a4be..362bed5427 100644 --- a/frontend/src/components/c-segment.vue +++ b/frontend/src/components/c-segment.vue @@ -1,8 +1,8 @@