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

Fix: Duplication in Puml errormessages; #122

Conversation

ZDI-StephanJoneleit
Copy link
Contributor

Assigned to Issue #121

We fixed the problem with the errormessages in puml by adding a cache like in the non-puml versions.
Duplication will be now filtered.

@ZDI-StephanJoneleit ZDI-StephanJoneleit force-pushed the 121_FixDuplicationsInPumlErrormessages branch from 21e5959 to 7825108 Compare September 27, 2021 08:44
@fgather
Copy link
Contributor

fgather commented Sep 27, 2021

Hi, @ZDI-StephanJoneleit ,

thanks for your contribution! I wonder if you could provide a test-case for this? Maybe @brandhuf could help out here?

@ZDI-StephanJoneleit
Copy link
Contributor Author

Hi, @ZDI-StephanJoneleit ,

thanks for your contribution! I wonder if you could provide a test-case for this? Maybe @brandhuf could help out here?

TestCase_ArchUniteNet_Issue121_PullRequest122.txt

We hope the test case will help you.

Remarks:
Issue, Fix and Docs are provided from one of our students.
He's doing his best to help you out.

Kind Regards,
your ZDI Team and Stephan Joneleit


//Prevent failDescriptions like "does depend on X and does depend on X and does depend on Y and does depend on Y
var failDescriptionCache = new List<string>();

foreach (var dependency in ruleType.GetTypeDependencies())
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder:
Instead of filtering afterwards, wouldn't Distinct() operation on the dependencies list or rather a DistinctBy on the dependencies with regard to the dependency.FullName property be easier to read?
DistinctBy in LINQ can be emulated with: dependency.GroupBy(p => p.FullName).Select(g => g.First())

Could you convert the very good testcase you provided (thanks again!) into an automated test? If you don't find the time I can do this as well, but it might take a while.

I'm happy to see that ArchUnitNet made its way to Zeiss :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Distinct is now implemented and tested.
The result stays the same but is now easier to read.

The automated test will be added later.

Also we want to thank You (all) for this great Open Source Project.
It does help us a lot for our .NET/Java Health Checks.
Especially the PlantUML Support is a huge help for larger projects.

… instead of during iteration;

Signed-off-by: Stephan Joneleit <[email protected]>
@ZDI-StephanJoneleit ZDI-StephanJoneleit force-pushed the 121_FixDuplicationsInPumlErrormessages branch from 1b7dd47 to a7846b0 Compare September 29, 2021 06:17
Signed-off-by: Stephan Joneleit <[email protected]>
@ZDI-StephanJoneleit ZDI-StephanJoneleit force-pushed the 121_FixDuplicationsInPumlErrormessages branch from a2deaea to 3db7197 Compare September 29, 2021 09:51
Remarks: I'm sorry but I was only able to run the test with an empty global.json file;
Signed-off-by: Stephan Joneleit <[email protected]>
@ZDI-StephanJoneleit ZDI-StephanJoneleit force-pushed the 121_FixDuplicationsInPumlErrormessages branch from 1c3c5ac to 8bc0147 Compare September 29, 2021 09:53
ArchUnit.sln Outdated
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.16
# Visual Studio Version 16
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'm Sorry, it looks like VS updated the Solution File on it's own.
It was not shown in the commits.

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'm sorry, but it didn't passed the automatic tests.
It might be due the changes in the solution file VS made on it's own (which was not shown in the commits)
and I had problems with the global.json file, which I had to clear so that the tests run.

I try my best to fix these problems.

Kind Regards:

  • Joneleit, Stephan

@ZDI-StephanJoneleit
Copy link
Contributor Author

That's how the test result would look like if the errormessage contains duplications:

Screenshot (5)

And that's how it should look like (successfull due no duplications):

Screenshot (6)

Fix: Unsupported SDK in global.json
-> SDK Version 5.0.203 cannot be downloaded on the official dotnet download page
(minimun 5.0.202 which is unfortunally not 5.0.203), that's why I included rollForward;

Signed-off-by: Stephan Joneleit <[email protected]>
global.json Outdated
@@ -1,5 +1,6 @@
{
"sdk": {
"version": "5.0.203"
"version": "5.0.203",
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 needed to change something in the global.json file.

Unfortunally, you only can download SDK Version 5.0.202 or 5.0.3xx from the official .NET Website.
Because my SDKs MUST match 5.0.203 (which you cannot download (maybe I only didn't found it) I use SDK 5.0.202 (which is lower) and SDK 5.0.3xx (which is the next feature version).

I do recommend to set version to 5.0.202 (which you still can download) and use an own rollForward (for example latestMajor/Minor (in the future when new features are added) (and on my machine was per default only installed the latest (SDK) version).

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 found the SDK 5.0.203 after a little deeper search.

…n the .NET Website because the Bot "Travis CI" failed

(maybe due different SDK Versions);

Signed-off-by: Stephan Joneleit <[email protected]>
@ZDI-StephanJoneleit
Copy link
Contributor Author

For some reasons the Update still does not pass throu Travis CI.
So you might need to do some tests manually to verify that the code is working.

I'll try my best to help you as good as I can, so feel free to contact me again.

Kind Regards,

  • Joneleit, Stephan; (Student) from Zeiss Digital Innovation

@ZDI-StephanJoneleit
Copy link
Contributor Author

For some reasons the Update still does not pass throu Travis CI. So you might need to do some tests manually to verify that the code is working.

I'll try my best to help you as good as I can, so feel free to contact me again.

Kind Regards,

  • Joneleit, Stephan; (Student) from Zeiss Digital Innovation

@fgather , do you have an Idea why it failed?

Could it be due the test I wrote and included?
Also it could be due the path to the puml (normally it should create the correct path (format) based on the OS (path format)).


var groups = splittedMessages.GroupBy(x => x.Trim().Trim('\t'));
var duplications = groups.Where(x => (x.Count() > 1
&& !String.IsNullOrWhiteSpace(x.FirstOrDefault()))
Copy link

Choose a reason for hiding this comment

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

Switch && and || to ensure Empty strings will be ignored.

!String.IsNullOrWhitespace(x.FirstOrDefaul) && (x.Count() > 1 || firstError.Contains(x.First()))

This would protect from errors due Empty or Whitespace strings (depending on the string inside FirstError).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Corrected

Signed-off-by: Stephan Joneleit <[email protected]>
@ZDI-StephanJoneleit
Copy link
Contributor Author

For some reasons the Update still does not pass throu Travis CI. So you might need to do some tests manually to verify that the code is working.
I'll try my best to help you as good as I can, so feel free to contact me again.
Kind Regards,

  • Joneleit, Stephan; (Student) from Zeiss Digital Innovation

@fgather , do you have an Idea why it failed?

Could it be due the test I wrote and included? Also it could be due the path to the puml (normally it should create the correct path (format) based on the OS (path format)).

Solved(?)

…rchUnitNET should be in there)

copy the classes for the PlantUML diagram to the TestAssembly (ExampleTests should only be used for examples and not for testing purposes)

Signed-off-by: Fritz Brandhuber <[email protected]>
…to 121_FixDuplicationsInPumlErrormessages

# Conflicts:
#	ArchUnitNet.MSTest.CheckErrormessages/PlantUMLErrormessagesCheck.cs
@brandhuf
Copy link
Contributor

brandhuf commented Oct 4, 2021

@ZDI-StephanJoneleit I created a PR to your branch with some improvements.

Mainly I moved the TestClass to the ArchUnitNETTests assembly, where all tests for ArchUnitNET should be. I also copied the classes for the PlantUML file to the TestAssembly, because ExampleTest should only contain examples and should not be used for testing. I also simplified the test a bit, because it was quite complicated before.

Can you please accept it? Afterwards we can merge this into master.

…sages

improvements to 121 fix duplications in puml errormessages
@fgather fgather merged commit 2db16b7 into TNG:main Oct 7, 2021
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.

4 participants