Skip to content

Conversation

@github-actions
Copy link
Contributor

You can preview this rule here (updated a few minutes after each push).

Review

A dedicated reviewer checked the rule description successfully for:

  • logical errors and incorrect information
  • information gaps and missing content
  • text style and tone
  • PR summary and labels follow the guidelines

@joke1196 joke1196 changed the title Create rule S7946 Create rule S7946: Custom logging formatters should not be used when built-in alternatives exist Sep 25, 2025
@sonarqube-next
Copy link

Quality Gate passed Quality Gate passed for 'rspec-tools'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
0 Dependency risks
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@sonarqube-next
Copy link

Quality Gate passed Quality Gate passed for 'rspec-frontend'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
0 Dependency risks
No data about Coverage
No data about Duplication

See analysis details on SonarQube

return template.format(**kwargs)

# Easy to forget the formatter
logging.info("User {action}: {amount:.2f} {item}") # Noncompliant
Copy link
Contributor

@guillaume-dequenne guillaume-dequenne Sep 26, 2025

Choose a reason for hiding this comment

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

Is this meant to be a f-string or template string?

Copy link
Contributor

@joke1196 joke1196 Oct 27, 2025

Choose a reason for hiding this comment

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

I think it would make sense to be either of them. But this whole example is really bad I will rewrite it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking about I am not sure how much we could detect if it is a t-string that is passed to a function and then used in a logging.xxxx method.

@joke1196 joke1196 changed the title Create rule S7946: Custom logging formatters should not be used when built-in alternatives exist Create rule S7946: Logging statements should use lazy evaluation to avoid performance overhead Oct 30, 2025
@joke1196
Copy link
Contributor

I have rewrote the rule to make more sense sadly this rule does not apply to Python 3.14 anymore.

@sonarqube-next
Copy link

Quality Gate passed Quality Gate passed for 'rspec-frontend'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
1 Dependency risk
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@sonarqube-next
Copy link

Quality Gate passed Quality Gate passed for 'rspec-tools'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
0 Dependency risks
No data about Coverage
No data about Duplication

See analysis details on SonarQube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants