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

Refactor FindingsReport + FileBasedFindingsReport #2454

Merged
merged 6 commits into from
Mar 25, 2020
Merged

Refactor FindingsReport + FileBasedFindingsReport #2454

merged 6 commits into from
Mar 25, 2020

Conversation

schalkms
Copy link
Member

No description provided.

}

/** Formats the debt time to a human readable format. */
fun formatDebtTime(): Debt {
Copy link
Member

@arturbosch arturbosch Mar 19, 2020

Choose a reason for hiding this comment

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

Shouldn't the overflow validation be moved to the toString() method or the function should be renamed to format and return just a String and toString just calls it?

Or should the overflow calculation be moved to the constructor? This introduces a new public api function.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wouldn't want to add the validation to the constructor.
The values would have to be mutable, which I wanted to avoid.
Maybe we can come up with a better name than formatDebtTime for this function.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we move this function to the companion object and call it Debt.recalculateOverflow(instance)?

Copy link
Member

Choose a reason for hiding this comment

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

I think that the plus operator should handle this problem. It's his responsability to create valid Debt instances.

If we want to do something in the constructor is to check that Debt is valid. And if it's not, throw an exception. But I think that it's not worth it.

@arturbosch arturbosch added this to the 1.7.0 milestone Mar 19, 2020
append(issuesString.yellow())
}
val overallDebt = debtList.reduce { acc, d -> acc + d }
append("Overall debt: $overallDebt".format("\n"))
Copy link
Member

@arturbosch arturbosch Mar 21, 2020

Choose a reason for hiding this comment

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

I think the overallDebt.formatDebtTime (Debt.recalculateOveflow(overallDebt)) call is missing here?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a bug. Thanks! I shall add a test for it.
The toString() method should call the formatDebtTime() function here.

@arturbosch arturbosch modified the milestones: 1.7.0, 1.7.1 Mar 22, 2020
}

/** Formats the debt time to a human readable format. */
fun formatDebtTime(): Debt {
Copy link
Member

Choose a reason for hiding this comment

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

I think that the plus operator should handle this problem. It's his responsability to create valid Debt instances.

If we want to do something in the constructor is to check that Debt is valid. And if it's not, throw an exception. But I think that it's not worth it.

@schalkms
Copy link
Member Author

If we want to do something in the constructor is to check that Debt is valid. And if it's not, throw an exception. But I think that it's not worth it.

Agreed.

@schalkms schalkms removed the blocked label Mar 25, 2020
@schalkms
Copy link
Member Author

I rebased the branch and incorporated your feedback in the last commit. This PR is now ready to merge.

@schalkms schalkms requested a review from BraisGabin March 25, 2020 17:59
@schalkms schalkms merged commit cec2d62 into detekt:master Mar 25, 2020
@schalkms schalkms deleted the refactor_reports2 branch March 25, 2020 18:32
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