Repository: apache/arrow
File: cpp/src/arrow/filesystem/azurefs.cc (C++)

Code before:
}

Result<AzureOptions> AzureOptions::FromUri(const Uri& uri, std::string* out_path) {
  AzureOptions options;
  options.ExtractFromUriSchemeAndHierPart(uri, out_path);
  RETURN_NOT_OK(options.ExtractFromUriQuery(uri));
  return options;
}

Result<AzureOptions> AzureOptions::FromUri(const std::string& uri_string,
                                           std::string* out_path) {
  Uri uri;
  RETURN_NOT_OK(uri.Parse(uri_string));
  return FromUri(uri, out_path);
}

bool AzureOptions::Equals(const AzureOptions& other) const {
  const bool equals =
      account_name == other.account_name &&
      blob_storage_authority == other.blob_storage_authority &&
      dfs_storage_authority == other.dfs_storage_authority &&
      blob_storage_scheme == other.blob_storage_scheme &&
      dfs_storage_scheme == other.dfs_storage_scheme &&
      default_metadata == other.default_metadata &&
      background_writes == other.background_writes &&
      credential_kind_ == other.credential_kind_ && account_key_ == other.account_key_ &&
      sas_token_ == other.sas_token_ && tenant_id_ == other.tenant_id_ &&
      client_id_ == other.client_id_ && client_secret_ == other.client_secret_;
  if (!equals) {
    return false;
  }
  switch (credential_kind_) {
    case CredentialKind::kDefault:
    case CredentialKind::kAnonymous:
      return true;
    case CredentialKind::kStorageSharedKey:
      return storage_shared_key_credential_->AccountName ==
             other.storage_shared_key_credential_->AccountName;
    case CredentialKind::kSASToken:
      return sas_token_ == other.sas_token_;
    case CredentialKind::kClientSecret:
    case CredentialKind::kCLI:
    case CredentialKind::kManagedIdentity:
    case CredentialKind::kWorkloadIdentity:
    case CredentialKind::kEnvironment:
      return token_credential_->GetCredentialName() ==
             other.token_credential_->GetCredentialName();
  }
  DCHECK(false);
  return false;
}

Review comment (refactor):
Can you keep one comparison per line and using that you have refactored it a bit keep them in alphabetical order for easier review?

Code after:
  return Status::OK();
}

Result<AzureOptions> AzureOptions::FromUri(const Uri& uri, std::string* out_path) {
  AzureOptions options;
  options.ExtractFromUriSchemeAndHierPart(uri, out_path);
  RETURN_NOT_OK(options.ExtractFromUriQuery(uri));
  return options;
}

Result<AzureOptions> AzureOptions::FromUri(const std::string& uri_string,
                                           std::string* out_path) {
  Uri uri;
  RETURN_NOT_OK(uri.Parse(uri_string));
  return FromUri(uri, out_path);
}

bool AzureOptions::Equals(const AzureOptions& other) const {
  const bool equals =
      account_name == other.account_name &&
      blob_storage_authority == other.blob_storage_authority &&
      dfs_storage_authority == other.dfs_storage_authority &&
      blob_storage_scheme == other.blob_storage_scheme &&
      dfs_storage_scheme == other.dfs_storage_scheme &&
      default_metadata == other.default_metadata &&
      background_writes == other.background_writes &&
      credential_kind_ == other.credential_kind_ && account_key_ == other.account_key_ &&
      sas_token_ == other.sas_token_ && tenant_id_ == other.tenant_id_ &&
      client_id_ == other.client_id_ && client_secret_ == other.client_secret_;
  if (!equals) {
    return false;
  }
  switch (credential_kind_) {
    case CredentialKind::kDefault:
    case CredentialKind::kAnonymous:
      return true;
    case CredentialKind::kStorageSharedKey:
      return storage_shared_key_credential_->AccountName ==
             other.storage_shared_key_credential_->AccountName;
    case CredentialKind::kSASToken:
      return sas_token_ == other.sas_token_;
    case CredentialKind::kClientSecret:
    case CredentialKind::kCLI:
    case CredentialKind::kManagedIdentity:
    case CredentialKind::kWorkloadIdentity:
    case CredentialKind::kEnvironment:
      return token_credential_->GetCredentialName() ==
             other.token_credential_->GetCredentialName();
  }
  DCHECK(false);
  return false;