Skip to content

Commit

Permalink
shorten format strings
Browse files Browse the repository at this point in the history
  • Loading branch information
nkzou committed Feb 15, 2024
1 parent 6c53166 commit 782091c
Show file tree
Hide file tree
Showing 14 changed files with 580 additions and 586 deletions.
4 changes: 2 additions & 2 deletions .generator/src/generator/templates/api.j2
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl {{ structName }} {
let operation_id = "{{ version }}.{{ operation.operationId | snake_case }}";
{%- if "x-unstable" in operation %}
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {}", operation_id);
warn!("Using unstable operation {operation_id}");
} else {
let local_error = UnstableOperationDisabledError {
msg: "Operation '{{ version }}.{{ operation.operationId | snake_case }}' is not enabled".to_string(),
Expand All @@ -131,7 +131,7 @@ impl {{ structName }} {
let local_client = &local_configuration.client;

let local_uri_str = format!(
"{}{{path}}",
"{}{{path}}",
local_configuration.get_operation_host(operation_id)
{%- for name, parameter in operation|parameters if parameter.in == "path" %}, {{ name|variable_name }}=
{%- if parameter.schema.type == "string" %}
Expand Down
7 changes: 2 additions & 5 deletions .generator/src/generator/templates/configuration.j2
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ impl ServerConfiguration {
for (name, variable) in &self.variables {
let value = variables.get(name).unwrap_or(&variable.default_value);
if !variable.enum_values.contains(value) && !variable.enum_values.is_empty() {
panic!(
"Value {} for variable {} is not in the enum values",
value, name
);
panic!("Value {value} for variable {name} is not in the enum values");
}
url = url.replace(&format!("{{ '{{{}}}' }}", name), &value);
url = url.replace(&format!("{{ '{{{name}}}' }}"), &value);
}
url
}
Expand Down
2 changes: 1 addition & 1 deletion .generator/src/generator/templates/function_mappings.j2
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn test_{{version}}_{{ operation['operationId'] | snake_case }}(world: &mut Data
world.response.object = serde_json::to_value(entity).unwrap();
}
},
_ => panic!("error parsing response: {}", error),
_ => panic!("error parsing response: {error}"),
};
}
};
Expand Down
7 changes: 2 additions & 5 deletions src/datadog/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,9 @@ impl ServerConfiguration {
for (name, variable) in &self.variables {
let value = variables.get(name).unwrap_or(&variable.default_value);
if !variable.enum_values.contains(value) && !variable.enum_values.is_empty() {
panic!(
"Value {} for variable {} is not in the enum values",
value, name
);
panic!("Value {value} for variable {name} is not in the enum values");
}
url = url.replace(&format!("{{{}}}", name), &value);
url = url.replace(&format!("{{{name}}}"), &value);
}
url
}
Expand Down
6 changes: 3 additions & 3 deletions src/datadogV1/api/api_slack_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl SlackIntegrationAPI {
let local_client = &local_configuration.client;

let local_uri_str = format!(
"{}/api/v1/integration/slack/configuration/accounts/{account_name}/channels/{channel_name}",
"{}/api/v1/integration/slack/configuration/accounts/{account_name}/channels/{channel_name}",
local_configuration.get_operation_host(operation_id), account_name=
urlencode(account_name)
, channel_name=
Expand Down Expand Up @@ -355,7 +355,7 @@ impl SlackIntegrationAPI {
let local_client = &local_configuration.client;

let local_uri_str = format!(
"{}/api/v1/integration/slack/configuration/accounts/{account_name}/channels/{channel_name}",
"{}/api/v1/integration/slack/configuration/accounts/{account_name}/channels/{channel_name}",
local_configuration.get_operation_host(operation_id), account_name=
urlencode(account_name)
, channel_name=
Expand Down Expand Up @@ -437,7 +437,7 @@ impl SlackIntegrationAPI {
let local_client = &local_configuration.client;

let local_uri_str = format!(
"{}/api/v1/integration/slack/configuration/accounts/{account_name}/channels/{channel_name}",
"{}/api/v1/integration/slack/configuration/accounts/{account_name}/channels/{channel_name}",
local_configuration.get_operation_host(operation_id), account_name=
urlencode(account_name)
, channel_name=
Expand Down
4 changes: 2 additions & 2 deletions src/datadogV2/api/api_dora_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl DORAMetricsAPI {
let local_configuration = &self.config;
let operation_id = "v2.create_dora_deployment";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {}", operation_id);
warn!("Using unstable operation {operation_id}");
} else {
let local_error = UnstableOperationDisabledError {
msg: "Operation 'v2.create_dora_deployment' is not enabled".to_string(),
Expand Down Expand Up @@ -174,7 +174,7 @@ impl DORAMetricsAPI {
let local_configuration = &self.config;
let operation_id = "v2.create_dora_incident";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {}", operation_id);
warn!("Using unstable operation {operation_id}");
} else {
let local_error = UnstableOperationDisabledError {
msg: "Operation 'v2.create_dora_incident' is not enabled".to_string(),
Expand Down
10 changes: 5 additions & 5 deletions src/datadogV2/api/api_incident_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl IncidentServicesAPI {
let local_configuration = &self.config;
let operation_id = "v2.create_incident_service";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {}", operation_id);
warn!("Using unstable operation {operation_id}");
} else {
let local_error = UnstableOperationDisabledError {
msg: "Operation 'v2.create_incident_service' is not enabled".to_string(),
Expand Down Expand Up @@ -249,7 +249,7 @@ impl IncidentServicesAPI {
let local_configuration = &self.config;
let operation_id = "v2.delete_incident_service";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {}", operation_id);
warn!("Using unstable operation {operation_id}");
} else {
let local_error = UnstableOperationDisabledError {
msg: "Operation 'v2.delete_incident_service' is not enabled".to_string(),
Expand Down Expand Up @@ -337,7 +337,7 @@ impl IncidentServicesAPI {
let local_configuration = &self.config;
let operation_id = "v2.get_incident_service";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {}", operation_id);
warn!("Using unstable operation {operation_id}");
} else {
let local_error = UnstableOperationDisabledError {
msg: "Operation 'v2.get_incident_service' is not enabled".to_string(),
Expand Down Expand Up @@ -428,7 +428,7 @@ impl IncidentServicesAPI {
let local_configuration = &self.config;
let operation_id = "v2.list_incident_services";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {}", operation_id);
warn!("Using unstable operation {operation_id}");
} else {
let local_error = UnstableOperationDisabledError {
msg: "Operation 'v2.list_incident_services' is not enabled".to_string(),
Expand Down Expand Up @@ -538,7 +538,7 @@ impl IncidentServicesAPI {
let local_configuration = &self.config;
let operation_id = "v2.update_incident_service";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {}", operation_id);
warn!("Using unstable operation {operation_id}");
} else {
let local_error = UnstableOperationDisabledError {
msg: "Operation 'v2.update_incident_service' is not enabled".to_string(),
Expand Down
10 changes: 5 additions & 5 deletions src/datadogV2/api/api_incident_teams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl IncidentTeamsAPI {
let local_configuration = &self.config;
let operation_id = "v2.create_incident_team";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {}", operation_id);
warn!("Using unstable operation {operation_id}");
} else {
let local_error = UnstableOperationDisabledError {
msg: "Operation 'v2.create_incident_team' is not enabled".to_string(),
Expand Down Expand Up @@ -244,7 +244,7 @@ impl IncidentTeamsAPI {
let local_configuration = &self.config;
let operation_id = "v2.delete_incident_team";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {}", operation_id);
warn!("Using unstable operation {operation_id}");
} else {
let local_error = UnstableOperationDisabledError {
msg: "Operation 'v2.delete_incident_team' is not enabled".to_string(),
Expand Down Expand Up @@ -327,7 +327,7 @@ impl IncidentTeamsAPI {
let local_configuration = &self.config;
let operation_id = "v2.get_incident_team";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {}", operation_id);
warn!("Using unstable operation {operation_id}");
} else {
let local_error = UnstableOperationDisabledError {
msg: "Operation 'v2.get_incident_team' is not enabled".to_string(),
Expand Down Expand Up @@ -416,7 +416,7 @@ impl IncidentTeamsAPI {
let local_configuration = &self.config;
let operation_id = "v2.list_incident_teams";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {}", operation_id);
warn!("Using unstable operation {operation_id}");
} else {
let local_error = UnstableOperationDisabledError {
msg: "Operation 'v2.list_incident_teams' is not enabled".to_string(),
Expand Down Expand Up @@ -524,7 +524,7 @@ impl IncidentTeamsAPI {
let local_configuration = &self.config;
let operation_id = "v2.update_incident_team";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {}", operation_id);
warn!("Using unstable operation {operation_id}");
} else {
let local_error = UnstableOperationDisabledError {
msg: "Operation 'v2.update_incident_team' is not enabled".to_string(),
Expand Down
Loading

0 comments on commit 782091c

Please sign in to comment.