misplaced-file

A file is in a language its place in the project does not allow.

Group
Code
Runs
Optional: run it with ur lint --rule misplaced-file
Level
warning
Reads
Every file
Fix
None: whether the file moves, is rewritten, or the declaration changes is a design choice

Why

The [architecture.languages] table in .ur/ur.toml says which languages the project's files may be in, where: each key is a glob from the project's root, which covers the files it matches and those under the directories it matches, and each value lists the only languages its files may be in, or is a table with only, the languages it forbids, the files it leaves alone (except), limits on how many files of a language it holds (at_most), nested = false to cover only the files the glob matches, and conventional = false to check conventional documents such as README.md and CODEOWNERS too. Every entry that covers a file holds for it. A language is one Ur reads, such as rust, python, shell, or urscal, or restructuredtext, org, asciidoc, or text, or the group prose. A file's language comes from its name, its extension, its first bytes, or its #! line, so a Python script without an extension is Python. Without the table, ur check keeps prose and text at the project's top to its conventional documents, and shell scripts to its top scripts directory.

The fix, as Ur suggests it: write the file in a language its place allows, or move it to a place that allows its language.

For agents

Before adding a file, check the [architecture.languages] table in .ur/ur.toml, and write it only in a language its place allows; never add a script in another language to work around it.

Example

.ur/ur.toml
[architecture.languages]
"docs" = ["prose", "data"]
"src" = { forbid = ["python"] }
src/count-rows
#!/usr/bin/env python3
import json
import sys

print(json.dumps({"rows": len(sys.stdin.readlines())}))
docs/reminder.rs
// regenerate the fixtures before the release
docs/notes.txt
Remember to regenerate the fixtures before the release.
What Ur prints
$ ur lint --rule misplaced-file
warning[misplaced-file]: `docs/notes.txt` is `text`, but `docs` holds only `prose`, `data`
  --> docs/notes.txt:1:1 this file
  = step 1: .ur/ur.toml:2:1 `docs` says so
  = hint: write the file in a language its place allows, or move it to a place that allows its language
warning[misplaced-file]: `docs/reminder.rs` is `rust`, but `docs` holds only `prose`, `data`
  --> docs/reminder.rs:1:1 this file
  = step 1: .ur/ur.toml:2:1 `docs` says so
  = hint: write the file in a language its place allows, or move it to a place that allows its language
warning[misplaced-file]: `src/count-rows` is `python`, which `src` forbids
  --> src/count-rows:1:1 this file
  = step 1: .ur/ur.toml:3:1 `src` says so
  = hint: write the file in a language its place allows, or move it to a place that allows its language
0 clone classes and 3 `misplaced-file` findings in 6 files

Try it in the playground →