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

Merge classes into ISolutionBindingRepository #5225

Conversation

ugras-ergun-sonarsource
Copy link
Contributor

Fixes #5210

@ugras-ergun-sonarsource ugras-ergun-sonarsource linked an issue Feb 13, 2024 that may be closed by this pull request
@@ -1,7 +1,7 @@
---
################################
# Assembly references report
# Report date/time: 2024-02-12T15:03:48.2745900Z
Copy link
Contributor Author

Choose a reason for hiding this comment

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

for some reason git created a conflict and didn't fixed itself even after merge from master. I had to manually resolve conflict and this happened.

Comment on lines +38 to +39
MefTestHelpers.CheckTypeCanBeImported<BoundConnectionInfoProvider, IBoundConnectionInfoProvider>(
MefTestHelpers.CreateExport<ISolutionBindingRepository>());
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity: What's the line length that you try to follow?

I saw that S103 is not active on SL. Should activate it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't have a rule for that. We decide what is more readable case by case. And I don't think it should be rule-based.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you fine with long lines too? For example, we have S103 configured to 200 on sonar-dotnet, to have some guidance. And we violateaccept it where it makes sense.

Comment on lines 114 to 125
var result = new List<BoundSonarQubeProject>();

var bindingConfigPaths = unintrusiveBindingPathProvider.GetBindingPaths();

foreach (var bindingConfigPath in bindingConfigPaths)
{
var boundSonarQubeProject = Read(bindingConfigPath);

if (boundSonarQubeProject == null) { continue; }

result.Add(boundSonarQubeProject);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO there are way too many empty lines in this method. It almost looks like semicolon-cr-lf-cr-lf is the command separator here.

{
}

internal BoundConnectionInfoProvider(IUnintrusiveBindingPathProvider unintrusiveBindingPathProvider, ISolutionBindingFileLoader solutionBindingFileLoader, IThreadHandling threadHandling)
internal BoundConnectionInfoProvider(ISolutionBindingRepository solutionBindingRepository, IThreadHandling threadHandling)

Choose a reason for hiding this comment

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

This class could have been a method of the repo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Repo is about read/write operations and more generic, but this class is about getting the unique connections for sloop. I would argue they are logically different things.

Choose a reason for hiding this comment

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

Still, this could be an extension method even if you don't want to make it a part of the main interface. This piece of functionality is too small to warrant a separate class

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 don't see having a small class as a problem. This class tackles a separate problem, I might merge the functionality here with converting to SLOOP Dto's (not sure yet how it'll be)

Choose a reason for hiding this comment

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

Merging with dtos makes more sense

if (boundSonarQubeProject == null) { continue; }

result.Add(ConvertToBindingInfo(boundSonarQubeProject));
result.Add(ConvertToBindingInfo(binding));

Choose a reason for hiding this comment

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

You don't need to have the conversion if you can directly read this class from json


public IEnumerable<BoundSonarQubeProject> List()
{
var result = new List<BoundSonarQubeProject>();

Choose a reason for hiding this comment

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

there's no need for list if you return IEnumerable. Also, for now we don't need to list the full list of bindings with QPs, we only need the connections. So, to simplify things, I would directly parse the connection info and return just that, unless you see a future need to return the full info.

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 don't see a future use but to keep things consistent using the same object with the rest of the methods makes more sense for me.

Choose a reason for hiding this comment

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

I don't think it's worth it to parse unnecessary data just to keep the interface slightly more clean. There are ways to minimize the difference between models and the methods used to parse them (generics, inheritance hierarchy of classes, etc.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using something like Generics... etc, would be an overkill. 99% of the time, this collection will have only one member and even if there are multiple connections, it won't be hundreds or even tens of connections.

Choose a reason for hiding this comment

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

I don't see generics as something that is too complicated to implement. And anyways, I was only using it as an example.


foreach (var bindingConfigPath in bindingConfigPaths)
{
var boundSonarQubeProject = Read(bindingConfigPath);

Choose a reason for hiding this comment

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

Reusing the read method is good, but we might not need to load the credentials for each connection. You could create a private read method with a flag to load credentials

Copy link

@ugras-ergun-sonarsource ugras-ergun-sonarsource merged commit f70c9cc into feature/sloop-rule-meta-data Feb 14, 2024
6 checks passed
@ugras-ergun-sonarsource ugras-ergun-sonarsource deleted the ue/Create-SolutionBindingRepository branch February 14, 2024 13:43
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.

Merge classes into ISolutionBindingRepository
3 participants