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

feature: only files in git will be considered in the report ALA-792 #485

Merged
merged 1 commit into from
Jan 2, 2024

Conversation

pedrobpereira
Copy link
Contributor

file name will be according to git file structure ALA-792

Copy link

codacy-production bot commented Dec 20, 2023

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+4.10% (target: -1.00%) 48.15%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (b09d0b0) 0 0 81.96%
Head commit (0794c46) 165 (+165) 142 (+142) 86.06% (+4.10%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#485) 27 13 48.15%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

@pedrobpereira pedrobpereira force-pushed the feature/git-only-files-report-ALA-792 branch 2 times, most recently from fb2db9a to ec585a9 Compare December 20, 2023 15:05
@pedrobpereira pedrobpereira requested review from lolgab and a team December 20, 2023 15:12
@pedrobpereira pedrobpereira marked this pull request as ready for review December 20, 2023 15:12
treeWalk.setRecursive(true)

val result: Seq[String] =
if (treeWalk.next) {
Copy link
Member

Choose a reason for hiding this comment

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

interesting if, is it really needed? Don't the continually take care of it? Also, should this return Stream explicitly? To know that the caller needs to consume this?

Copy link
Contributor Author

@pedrobpereira pedrobpereira Dec 21, 2023

Choose a reason for hiding this comment

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

Yeah, I think it is needed, I'll test this again without, but I added it because it was failing without the first next. Since return type is typified, I don't think we have to worry about that right?, whoever is consuming will only interact with a Seq.

private def transform(
report: CoverageReport
)(config: ReportConfig, acceptableFileNames: Seq[String]): CoverageReport = {
val transformations = Set(new PathPrefixer(config.prefix), new GitFileNameUpdaterAndFilter(acceptableFileNames))
Copy link
Member

Choose a reason for hiding this comment

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

Be careful with the the Set here, probably we should change to a Seq. Since Set does not guarantee order, and we should guarantee that the GitFileNameUpdaterAndFilteris the last transformation

files
.map { file =>
logger.info(s"Parsing coverage data from: ${file.getAbsolutePath} ...")
for {
_ <- validateFileAccess(file)
files <- gitFiles
Copy link
Member

Choose a reason for hiding this comment

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

We can consider this for to allow for optional files maybe? So we fallback to not doing this new mechanism if anything fails

fileReport <- report.fileReports
fileName <- FileNameMatcher
.matchAndReturnName(fileReport.filename, acceptableFileNames)
.map(Some(_))
Copy link
Member

Choose a reason for hiding this comment

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

Strange code here, maybe an .orElse on the log, is that what you want?

Choose a reason for hiding this comment

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

I think it looks bloated even with .orElse. Maybe move it outside:

  [...]
    fileName <- matchFileName(fileReport)
  [...]

  private def matchFileName(fileReport: CoverageFileReport): Option[String] = {
    val maybeFileName = FileNameMatcher.matchAndReturnName(fileReport.filename, acceptableFileNames)

    if (maybeFileName.isEmpty)
      logger.warn(s"File: ${fileReport.filename} will be discarded and will not be considered for coverage calculation")

    maybeFileName
  }

@pedrobpereira pedrobpereira force-pushed the feature/git-only-files-report-ALA-792 branch 7 times, most recently from e51096d to 3dd10db Compare December 21, 2023 16:15
machadoit
machadoit previously approved these changes Dec 21, 2023
Copy link
Member

@machadoit machadoit left a comment

Choose a reason for hiding this comment

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

LGTM!

…e will be according to git file structure ALA-792
@pedrobpereira pedrobpereira force-pushed the feature/git-only-files-report-ALA-792 branch from 3dd10db to 0794c46 Compare December 21, 2023 16:43
@pedrobpereira pedrobpereira marked this pull request as draft December 22, 2023 09:52
@pedrobpereira
Copy link
Contributor Author

Converted to Draft again to prevent someone merging this, we will be waiting till the 1st week of January to go ahead with this.

@pedrobpereira pedrobpereira marked this pull request as ready for review January 2, 2024 09:37
@pedrobpereira pedrobpereira merged commit e523b20 into master Jan 2, 2024
18 checks passed
@pedrobpereira pedrobpereira deleted the feature/git-only-files-report-ALA-792 branch January 2, 2024 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants