Skip to content

Issues from a universal cache are reported at the path of the machine that made the cache #9427

Description

@Jason3S

Summary

A cache made with cacheFormat: universal stores file paths relative to the cache, so it can be reused after the project moves, for example to another machine or another checkout folder. But the spelling issues it stores keep the absolute file URL. After a move, cached issues are reported at the old location.

Steps to reproduce

  1. In folder a, create doc.md containing This has a speling mistake. and a cspell.json:

    { "cache": { "useCache": true, "cacheStrategy": "content", "cacheFormat": "universal" } }
  2. Run cspell doc.md in a.

  3. Copy folder a, including .cspellcache, to folder b.

  4. Run cspell doc.md in b.

Expected

doc.md:1:12 - Unknown word (speling) fix: (spelling)
CSpell: Files checked: 1 (1 from cache), Issues found: 1 in 1 file.

Actual

/…/a/doc.md:1:12 - Unknown word (speling) fix: (spelling)
CSpell: Files checked: 1 (1 from cache), Issues found: 1 in 1 file.

The result comes from the cache, but the issue points at folder a, which may not exist on this machine. Running with --no-cache in b reports doc.md.

Seen in every version tested, from 6.31.3 to 10.3.6.

Missing test

The cache tests use a sample project with no spelling issues, and only count how many files were checked and how many came from the cache. A cached result only carries a file path when the file has an issue, so the tests never stored one. That's likely why this went unnoticed.

A test with a misspelled word that lints a project, copies it with its cache to another folder, and expects the cached issues to match a --no-cache run would catch it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions