rust-lang / rust-lang/rust-clippy

The "Clippy Lints" page looks like it is censored

Open Beginner friendly
#16,981 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-documentation A-website C-bug
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Summary

This page, for example, renders thusly in Firefox:

Image

This is likely due to my browser having a default policy of refusing cookies/etc., because why, in the year 2026, are you still accepting cookies from sites that have no business setting them? (That said, I do understand most people roll with the default of "yolo".)

Anyways, the page's JavaScript is attempting to do something with browser storage (e.g., localStorage or similar):

Uncaught DOMException: The operation is insecure.
    loadValue https://rust-lang.github.io/rust-clippy/master/theme.js:10
    <anonymous> https://rust-lang.github.io/rust-clippy/master/theme.js:56
    <anonymous> https://rust-lang.github.io/rust-clippy/master/theme.js:69

And I am guessing that that failure leads to subsequent JS-induced changes to the page's styling not taking effect.

The stack, expanded:

function loadValue(settingName) {
    return localStorage.getItem(`clippy-lint-list-${settingName}`);
}

called from,

(function() {
    // This file is loaded first. If so, we add the `js` class on the `<html>`
    // element.
    document.documentElement.classList.add("js");

    // loading the theme after the initial load
    const prefersDark = window.matchMedia("(prefers-color-scheme: dark)");
    const theme = loadValue("theme");    // ⇐
    if (prefersDark.matches && !theme) {
        setTheme("coal", false);
    } else {
        setTheme(theme, false);
    }

    const themeChoice = document.getElementById("theme-choice");

    themeChoice.value = loadValue("theme");
    document.getElementById("theme-choice").addEventListener("change", (e) => {
        setTheme(themeChoice.value, true);
    });
})();

I think if loadValue just handled the error case from the call to localStorage, and returned null, that should work?
(And probably some similar handling to just skip the latter block, and to avoid calling loadValue twice.)

(It also seems like there's basically just this one CSS style,

@media (prefers-color-scheme: dark) {
  body:not([class]) {
    --inline-code-bg: #1d1f21;
  }
}

That directly uses prefers-color-scheme? So that's why that one doesn't need the JS to "function", but of course, the rest of the page does, so you end up with just that in dark mode. (And even then, only the BG color. The FG color refers to an undef'd CSS var.)

Reproducer

Load the page above w/ cookies disabled.

Current output: Censored page.

Desired output: Readable page.

Version

Additional Labels

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in theme.js, especially loadValue and the initialization block shown in the report. Reproduce the issue by loading the Clippy lints page in Firefox with cookies or browser storage disabled, then handle the localStorage failure without preventing the page styling from being applied. Done means the page remains readable under that configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.