Skip to content

Excessive String Formatting #28

@Benji918

Description

@Benji918

Code Analysis Issue

Severity: Low
File: Multiple files, particularly in URL construction.

Description

Recommendation

  1. Use urllib.parse.urljoin: For constructing URLs, use urllib.parse.urljoin to ensure correct URL joining and escaping. This is generally safer and more readable than manual string concatenation.
    2. Pre-compute static parts: If parts of a string are static, pre-compute them outside the loop to avoid repeated string formatting.
import urllib.parse

base_url = "https://api.github.com/repos"

# Instead of:
# url = f'https://api.github.com/repos/{owner}/{repo}/pulls?state=all'

# Use:
url = urllib.parse.urljoin(f"{base_url}/{owner}/{repo}/", "pulls?state=all")

This issue was automatically generated by code analysis.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions