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

SLVS-1431 Add server connection json model and mapper #5658

Conversation

gabriela-trutan-sonarsource
Copy link
Contributor

@gabriela-trutan-sonarsource gabriela-trutan-sonarsource commented Sep 2, 2024

…aps the model from the logic model to the json model and vice-versa
@terraform-techuser terraform-techuser changed the title SLVS-1431 Add server connection json model and mapper SLVS-1431 Add server connection json model and mapper Sep 2, 2024
Copy link

sonarqubecloud bot commented Sep 2, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 85%)

See analysis details on SonarCloud

@@ -25,7 +25,7 @@ public abstract class ServerConnection
internal static readonly ServerConnectionSettings DefaultSettings = new(true);

public string Id { get; }
public ServerConnectionSettings Settings { get; }
public ServerConnectionSettings Settings { get; set; }

Choose a reason for hiding this comment

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

Why was the setter added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because in the repository we have TryUpdateSettingsById, which requires to add the settings to an existing ServerConnection model

Choose a reason for hiding this comment

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

I don't know if we should do that. Feels like a thread safety issue. The model can be modified from another thread. Could we make it immutable? Would that have big implications on other parts of the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the repository, I am reading the file and then retrieving the ServerConnection model for the provided Id. I then have to update the settings:
image

I either allow modification of the settings or I need to create a new instance of the ServerConnection (which is immutable), then remove it from the list, then re-add the new instance. This feels a lot more error-prone and unexpected.

I could make instead the IsSmartNotificationsEnabled editable (add a setter for it). Also I don't think we should be too paranoid about the multi-threading. Because all the write operations to the connections should only happen via the UI. And the UI will be blocked while anything in the connection is modified

@gabriela-trutan-sonarsource gabriela-trutan-sonarsource merged commit 61c9605 into feature/new-connected-mode Sep 3, 2024
7 of 8 checks passed
@gabriela-trutan-sonarsource gabriela-trutan-sonarsource deleted the gt/json-server-connection-model branch September 3, 2024 08: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.

2 participants