Skip to content

Skip localhost URLs in link checker#348

Closed
Copilot wants to merge 2 commits into4.6.xfrom
copilot/optimize-check-links-scripts
Closed

Skip localhost URLs in link checker#348
Copilot wants to merge 2 commits into4.6.xfrom
copilot/optimize-check-links-scripts

Conversation

Copy link
Contributor

Copilot AI commented Feb 13, 2026

Link checker was attempting network connections to localhost URLs in documentation examples, causing unnecessary timeouts and false positives.

Changes

  • Added _is_localhost_url() to detect localhost patterns before network calls
  • Updated _should_skip_url() to filter localhost URLs during link extraction

Localhost patterns handled

  • localhost (any port)
  • 127.x.x.x (entire loopback range)
  • [::1] (IPv6 localhost with bracket parsing)
  • 0.0.0.0

Implementation

def _is_localhost_url(self, url: str) -> bool:
    parsed = urlparse(url)
    if not parsed.netloc:
        return False
    
    netloc = parsed.netloc.lower()
    # Handle IPv6 bracket notation: [::1]:port
    if netloc.startswith('['):
        hostname = netloc.split(']')[0] + ']'
    else:
        hostname = netloc.split(':')[0]
    
    localhost_patterns = ['localhost', '127.0.0.1', '[::1]', '0.0.0.0']
    return hostname in localhost_patterns or hostname.startswith('127.')

URLs are filtered before entering the checking pipeline, eliminating connection attempts entirely.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.amazon.com
    • Triggering command: /usr/bin/python3 python3 bin/quality/check-links.py docs/rest-api-examples.md (dns block)
  • www.google.com
    • Triggering command: /usr/bin/python3 python3 bin/quality/check-links.py /tmp/link-checker-test/test-localhost.md --root /tmp/link-checker-test (dns block)
    • Triggering command: /usr/bin/python3 python3 /home/REDACTED/work/Browser4/Browser4/bin/quality/check-links.py /tmp/link-checker-test/test-localhost.md --root /tmp/link-checker-test (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Add _is_localhost_url method to detect localhost patterns
- Skip localhost, 127.x.x.x, [::1], and 0.0.0.0 URLs
- Handle IPv6 addresses in brackets correctly
- Tested with comprehensive localhost URL patterns

Co-authored-by: galaxyeye <1701451+galaxyeye@users.noreply.github.com>
Copilot AI changed the title [WIP] Optimize check-links scripts to ignore localhost connections Skip localhost URLs in link checker Feb 13, 2026
Copilot AI requested a review from galaxyeye February 13, 2026 13:33
@github-actions
Copy link

Qodana for JVM

1660 new problems were found

Inspection name Severity Problems
Incorrect Spring Core XML-based application context 🔴 Failure 455
Incorrect constructor injection in XML Spring bean 🔴 Failure 4
Malicious dependency 🔴 Failure 2
Unresolved reference in KDoc 🔶 Warning 208
Unreachable code 🔶 Warning 78
Assigned value is never read 🔶 Warning 10
Kotlin Maven Plugin misconfigured 🔶 Warning 10
Copy constructor misses field 🔶 Warning 8
Non-serializable class with 'serialVersionUID' 🔶 Warning 8
Method does not call super method 🔶 Warning 8
Static initializer references subclass 🔶 Warning 8
Constant conditions 🔶 Warning 5
Statement with empty body 🔶 Warning 4
Suspicious collection method call 🔶 Warning 4
Nullability and data flow problems 🔶 Warning 3
Nullable type argument in Java collection that doesn't support nulls 🔶 Warning 3
Single character alternation 🔶 Warning 3
Non-safe string is used as SQL 🔶 Warning 3
Unused assignment 🔶 Warning 3
Duplicate character in character class 🔶 Warning 2
Variable is never read 🔶 Warning 2
Wrapper type may be primitive 🔶 Warning 2
'equals()' and 'hashCode()' not paired 🔶 Warning 1
Malformed format string 🔶 Warning 1
Mismatched query and update of collection 🔶 Warning 1
Unnecessary non-capturing group 🔶 Warning 1
Call to 'System.getProperty(str)' could be simplified 🔶 Warning 1
Function or property has platform type ◽️ Notice 793
Redundant interpolation prefix ◽️ Notice 21
Constant conditions ◽️ Notice 4
Argument could be converted to 'Set' to improve performance ◽️ Notice 3
Constant values ◽️ Notice 1

☁️ View the detailed Qodana report

Detected 10 dependencies

Third-party software list

This page lists the third-party software dependencies used in project

Dependency Version Licenses
cdt-kotlin-client 4.0.0 Apache-2.0
crawler-commons 0.5 Apache-2.0
gora-shaded-mongodb 0.9 Apache-2.0
kotlin-sdk-client-jvm 0.8.1 MIT
kotlin-sdk-core-jvm 0.8.1 MIT
playwright 1.50.0 Apache-2.0
snakeyaml 2.2 Apache-2.0
springdoc-openapi-starter-webmvc-ui 2.6.0 Apache-2.0
stax2-api 4.2.1 BSD-3-Clause
woodstox-core-asl 4.4.1 Apache-2.0
Contact Qodana team

Contact us at qodana-support@jetbrains.com

@galaxyeye galaxyeye closed this Mar 2, 2026
@galaxyeye galaxyeye deleted the copilot/optimize-check-links-scripts branch March 2, 2026 07:01
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.

2 participants