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

SLCORE-1110 sq ide connected mode works with multi regions support in sqc #1225

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

kirill-knize-sonarsource
Copy link
Contributor

For SonarSourcers:

  • Prefix the commit message with the ticket number, i.e. SLCORE-XXXX if you already have a ticket in Jira
  • For standalone PRs without issue in Jira:
    • Mention Epic ID in this descrition to create a new Task in Jira
    • Mention Issue ID in this descrition to create a new Sub-Task in Jira
    • Do not mention any Jira issue to create a new Task in Jira without a parent
  • When changing an API:
    • Explain in the JavaDoc the purpose of the new API
    • Document the change in API_CHANGES.md
    • If the change breaks the current API, explicitly communicate those to the impacted consumers prior to merging (eg. IDE squad)
  • Make sure the tests adhere to the convention:
    • All test method names should use snake_case, for example: test_validate_input.
  • Make sure checks are green: build passes, Quality Gate is green

For external contributors:

In addition to the above, please review our contribution guidelines and ensure your pull request adheres to the following guidelines:

  • Please explain your motives to contribute this change: what problem you are trying to fix, what improvement you are trying to make
  • Use the following formatting style: SonarSource/sonar-developer-toolset
  • Provide a unit test for any code you changed

@kirill-knize-sonarsource kirill-knize-sonarsource force-pushed the feature/kk/SLCORE-1110-SQ-IDE-Connected-Mode-works-with-multi-regions-support-in-SQC branch from 00bf001 to 1295e66 Compare January 27, 2025 11:58
@sophio-japharidze-sonarsource sophio-japharidze-sonarsource force-pushed the feature/kk/SLCORE-1110-SQ-IDE-Connected-Mode-works-with-multi-regions-support-in-SQC branch 4 times, most recently from 69280bb to 668f1bd Compare January 28, 2025 15:45
@kirill-knize-sonarsource kirill-knize-sonarsource force-pushed the feature/kk/SLCORE-1110-SQ-IDE-Connected-Mode-works-with-multi-regions-support-in-SQC branch from f8232a3 to d234a0d Compare January 30, 2025 09:28
Copy link
Contributor

@damien-urruty-sonarsource damien-urruty-sonarsource left a comment

Choose a reason for hiding this comment

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

Quite a few comments, but nothing major.

@@ -219,7 +220,7 @@ private static BindingProperties extractConnectionProperties(ClientFile matchedF
return null;
}
return new BindingProperties(getAndTrim(properties, "sonar.projectKey"), getAndTrim(properties, "sonar.organization"),
getAndTrim(properties, "sonar.host.url"), false);
getAndTrim(properties, "sonar.host.url"), null, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know what is the plan to support the US region regarding the .sonarcloud.properties file? Should users specify a different sonar.host.url? There might be something to do here other than setting the region to null

try {
configuredRegion = region != null ? SonarCloudRegion.valueOf(region) : SonarCloudRegion.EU;
} catch (IllegalArgumentException e) {
LOG.warn("Unknown region '{}'", region);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you give a bit more details in the trace? It's a bit short and lacks context

}
}

@CheckForNull
private BindingClue computeBindingClue(String filename, BindingProperties scannerProps) {
if (AUTOSCAN_CONFIG_FILENAME.equals(filename)) {
return new SonarCloudBindingClue(scannerProps.projectKey, scannerProps.organization, scannerProps.isFromSharedConfiguration);
return new SonarCloudBindingClue(scannerProps.projectKey, scannerProps.organization, null, scannerProps.isFromSharedConfiguration);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question here, is there a way to figure out the region?

if (removeEnd(scannerProps.serverUrl, "/").equals(removeEnd(sonarCloudUri.toString(), "/"))) {
return new SonarCloudBindingClue(scannerProps.projectKey, null, scannerProps.isFromSharedConfiguration);
if (sonarCloudActiveEnvironment.isSonarQubeCloud(scannerProps.serverUrl)) {
return new SonarCloudBindingClue(scannerProps.projectKey, null, scannerProps.region, scannerProps.isFromSharedConfiguration);
Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm not wrong, the scannerProps.region will be null here in some cases, while the URL might be detected as the US region, and the null will lead to selecting the EU region, is it the case?

@@ -346,6 +359,10 @@ public String getOrganization() {
return organization;
}

public SonarCloudRegion getRegion() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be annotated @CheckForNull?

public GetOrganizationParams(Either<TokenDto, UsernamePasswordDto> credentials, String organizationKey) {
this(credentials, organizationKey, SonarCloudRegion.EU);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, deprecation to be documented.

public ListUserOrganizationsParams(Either<TokenDto, UsernamePasswordDto> credentials) {
this(credentials, SonarCloudRegion.EU);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, deprecation to be documented

public SonarCloudConnectionParams(String organizationKey, @Nullable String tokenName, @Nullable String tokenValue) {
this(organizationKey, tokenName, tokenValue, SonarCloudRegion.EU);
Copy link
Contributor

Choose a reason for hiding this comment

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

Here I'm not sure we need a deprecation. Clients are not supposed to call the constructor, they will receive an instance. But maybe for safety we can keep the deprecation. If we keep it, we should document it

public SonarCloudConnectionSuggestionDto(String organization, String projectKey) {
this(organization, projectKey, SonarCloudRegion.EU);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same


public SonarCloudActiveEnvironment(URI uri, URI webSocketsEndpointUri) {
this.uri = uri;
this.webSocketsEndpointUri = webSocketsEndpointUri;
this.uris = Map.of(SonarCloudRegion.EU, new SonarQubeCloudUris(uri, webSocketsEndpointUri));
Copy link
Contributor

Choose a reason for hiding this comment

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

This constructor is used if clients provide a custom URI. The risk here is that we don't define the US region in the map. Should we allow clients to also customize US URIs?

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