diff --git a/.codespell.rc b/.codespell.rc new file mode 100644 index 000000000..914ca2951 --- /dev/null +++ b/.codespell.rc @@ -0,0 +1,3 @@ +[codespell] +ignore-words-list = crate +skip = ./.git/**,./.vscode/cspell.dictionaries/**,./target/**,./tests/fixtures/** diff --git a/.editorconfig b/.editorconfig index 95dfec676..d93fa7c0e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,22 +3,38 @@ # * top-most EditorConfig file root = true -# Unix-style newlines with a newline ending every file [*] +# default ~ utf-8, unix-style newlines with a newline ending every file, 4 space indentation charset = utf-8 end_of_line = lf indent_size = 4 indent_style = space insert_final_newline = true +max_line_length = 100 trim_trailing_whitespace = true -[*.{bat,cmd,[Bb][Aa][Tt],[Cc][Mm][Dd]}] -# DOS/Win requires BAT/CMD files to have CRLF EOLNs -end_of_line = crlf - -[[Mm]akefile{,.*}] -# TAB-style indentation +[[Mm]akefile{,.*}, *.{mk,[Mm][Kk]}] +# makefiles ~ TAB-style indentation indent_style = tab -[*.{yml,[Yy][Mm][Ll]}] +[*.{bat,cmd,[Bb][Aa][Tt],[Cc][Mm][Dd]}] +# BAT/CMD ~ DOS/Win requires BAT/CMD files to have CRLF EOLNs +end_of_line = crlf + +[*.go] +# go ~ TAB-style indentation (SPACE-style alignment); ref: @@ +indent_style = tab + +[*.{cjs,js,json,mjs,ts}] +# js/ts indent_size = 2 + +[*.{markdown,md,mkd,[Mm][Dd],[Mm][Kk][Dd],[Mm][Dd][Oo][Ww][Nn],[Mm][Kk][Dd][Oo][Ww][Nn],[Mm][Aa][Rr][Kk][Dd][Oo][Ww][Nn]}] +# markdown +indent_size = 2 +indent_style = space + +[*.{yaml,yml,[Yy][Mm][Ll],[Yy][Aa][Mm][Ll]}] +# YAML +indent_size = 2 +indent_style = space diff --git a/.github/stale.yml b/.github/stale.yml index e0988d0bd..b614226dc 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,4 +1,5 @@ -# Number of days of inactivity before an issue/PR becomes stale +# spell-checker:ignore (labels) wontfix + # Number of days of inactivity before an issue/PR becomes stale daysUntilStale: 365 # Number of days of inactivity before a stale issue/PR is closed daysUntilClose: 365 diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 5ac9295d4..4ce9e556d 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -5,7 +5,7 @@ name: CICD # spell-checker:ignore (jargon) SHAs deps softprops toolchain # spell-checker:ignore (names) CodeCOV MacOS MinGW Peltoche rivy # spell-checker:ignore (shell/tools) choco clippy dmake dpkg esac fakeroot gmake grcov halium lcov libssl mkdir popd printf pushd rustc rustfmt rustup shopt xargs -# spell-checker:ignore (misc) aarch alnum armhf coreutils gnueabihf issuecomment maint nullglob onexitbegin onexitend tempfile uutils +# spell-checker:ignore (misc) aarch alnum armhf bindir busytest coreutils gnueabihf issuecomment maint nullglob onexitbegin onexitend tempfile testsuite uutils env: PROJECT_NAME: coreutils @@ -58,6 +58,24 @@ jobs: # * convert any warnings to GHA UI annotations; ref: S=$(find tests -name "*.rs" -print0 | xargs -0 cargo fmt -- --check) && printf "%s\n" "$S" || { printf "%s\n" "$S" | sed -E -n "s/^Diff[[:space:]]+in[[:space:]]+${PWD//\//\\/}\/(.*)[[:space:]]+at[[:space:]]+[^0-9]+([0-9]+).*$/::warning file=\1,line=\2::WARNING: \`cargo fmt\`: style violation/p" ; } + code_spellcheck: + name: Style/spelling + runs-on: ${{ matrix.job.os }} + strategy: + matrix: + job: + - { os: ubuntu-latest } + steps: + - uses: actions/checkout@v1 + - name: Install/setup prerequisites + shell: bash + run: | + sudo apt-get -y update ; sudo apt-get -y install npm ; sudo npm install cspell -g; + - name: Run `cspell` + shell: bash + run: | + cspell --config .vscode/cSpell.json --no-summary --no-progress **/* | sed "s/\(.*\):\(.*\):\(.*\) - \(.*\)/::warning file=\1,line=\2,col=\3::cspell: \4/" || true + code_warnings: name: Style/warnings runs-on: ${{ matrix.job.os }} @@ -614,20 +632,3 @@ jobs: flags: ${{ steps.vars.outputs.CODECOV_FLAGS }} name: codecov-umbrella fail_ci_if_error: false - spellcheck: - name: Spell Check - runs-on: ${{ matrix.job.os }} - strategy: - matrix: - job: - - { os: ubuntu-latest } - steps: - - uses: actions/checkout@v1 - - name: Install/setup prerequisites - shell: bash - run: | - sudo apt-get -y update ; sudo apt-get -y install npm ; sudo npm install cspell -g; - - name: Run `cspell` - shell: bash - run: | - cspell --config .vscode/cSpell.json --no-summary --no-progress $( git ls-files | grep "\.\(rs\|md\)" ) | sed "s/\(.*\):\(.*\):\(.*\) - \(.*\)/::warning file=\1,line=\2,col=\3::cspell: \4/" || true diff --git a/.vscode/cSpell.json b/.vscode/cSpell.json index 8561d69ad..9869923a4 100644 --- a/.vscode/cSpell.json +++ b/.vscode/cSpell.json @@ -1,352 +1,19 @@ // `cspell` settings { - "version": "0.1", // Version of the setting file. Always 0.1 - "language": "en", // language - current active spelling language - // ignoreWords - "ignoreWords": [ - // abbrev/acronyms - "Cygwin", - "FreeBSD", - "Gmail", - "GNUEABI", - "GNUEABIhf", - "Irix", - "MacOS", - "MinGW", - "Minix", - "MS-DOS", - "MSDOS", - "NetBSD", - "Novell", - "OpenBSD", - "POSIX", - "SELinux", - "Solaris", - "Xenix", - "flac", - "lzma", - // cargo - "cdylib", - "rlib", - // crates - "advapi", - "advapi32-sys", - "aho-corasick", - "backtrace", - "byteorder", - "chacha", - "chrono", - "conv", - "corasick", - "filetime", - "formatteriteminfo", - "getopts", - "itertools", - "memchr", - "multifilereader", - "onig", - "peekreader", - "quickcheck", - "rand_chacha", - "smallvec", - "tempfile", - "termion", - "termios", - "termsize", - "termwidth", - "textwrap", - "walkdir", - "winapi", - "xattr", - // jargon - "AST", // abstract syntax tree - "CPU", - "CPUs", - "FIFO", - "FIFOs", - "FQDN", // fully qualified domain name - "GID", // group ID - "GIDs", - "POSIXLY", - "RNG", // random number generator - "RNGs", - "UID", // user ID - "UIDs", - "UUID", // universally unique identifier - "arity", - "bitmask", - "canonicalization", - "canonicalize", - "colorizable", - "colorize", - "consts", - "dedup", - "demangle", - "deque", - "dequeue", - "enqueue", - "executable", - "executables", - "gibibytes", - "hardfloat", - "hardlink", - "hardlinks", - "hashsums", - "kibibytes", - "mebibytes", - "mergeable", - "multibyte", - "nonportable", - "peekable", - "precompiled", - "precompute", - "preload", - "prepend", - "prepended", - "primality", - "pseudoprime", - "pseudoprimes", - "procs", - "readonly", - "seedable", - "semver", - "shortcode", - "shortcodes", - "symlink", - "symlinks", - "syscall", - "toekenize", - "unbuffered", - "unportable", - "whitespace", - // names - "Akira Hayakawa", "Akira", "Hayakawa", - "Alan Andrade", "Alan", "Andrade", - "Alex Lyon", "Alex", "Lyon", - "Alexander Batischev", "Alexander", "Batischev", - "Aleksander Bielawski", "Aleksander", "Bielawski", - "Alexander Fomin", "Alexander", "Fomin", - "Anthony Deschamps", "Anthony", "Deschamps", - "Ben Eills", "Ben", "Eills", - "Ben Hirsch", "Ben", "Hirsch", - "Benoit Benedetti", "Benoit", "Benedetti", - "Boden Garman", "Boden", "Garman", - "Chirag B Jadwani", "Chirag", "Jadwani", - "Derek Chiang", "Derek", "Chiang", - "Dorota Kapturkiewicz", "Dorota", "Kapturkiewicz", - "Evgeniy Klyuchikov", "Evgeniy", "Klyuchikov", - "Fangxu Hu", "Fangxu", "Hu", - "Gil Cottle", "Gil", "Cottle", - "Haitao Li", "Haitao", "Li", - "Inokentiy Babushkin", "Inokentiy", "Babushkin", - "Joao Oliveira", "Joao", "Oliveira", - "Jeremiah Peschka", "Jeremiah", "Peschka", - "Jian Zeng", "Jian", "Zeng", - "Jimmy Lu", "Jimmy", "Lu", - "Jordi Boggiano", "Jordi", "Boggiano", - "Jordy Dickinson", "Jordy", "Dickinson", - "Joseph Crail", "Joseph", "Crail", - "Joshua S Miller", "Joshua", "Miller", - "KokaKiwi", - "Konstantin Pospelov", "Konstantin", "Pospelov", - "Mahkoh", - "Maciej Dziardziel", "Maciej", "Dziardziel", - "Michael Gehring", "Michael", "Gehring", - "Martin Kysel", "Martin", "Kysel", - "Morten Olsen Lysgaard", "Morten", "Olsen", "Lysgaard", - "Nicholas Juszczak", "Nicholas", "Juszczak", - "Nick Platt", "Nick", "Platt", - "Orvar Segerström", "Orvar", "Segerström", - "Peter Atashian", "Peter", "Atashian", - "Rolf Morel", "Rolf", "Morel", - "Roman Gafiyatullin", "Roman", "Gafiyatullin", - "Roy Ivy III", "Roy", "Ivy", "III", - "Sergey 'Shnatsel' Davidoff", "Sergey", "Shnatsel", "Davidoff", - "Sokovikov Evgeniy", "Sokovikov", "Evgeniy", - "Sunrin SHIMURA", "Sunrin", "SHIMURA", - "Smigle00", "Smigle", - "Sylvestre Ledru", "Sylvestre", "Ledru", - "T Jameson Little", "Jameson", "Little", - "Tobias Bohumir Schottdorf", "Tobias", "Bohumir", "Schottdorf", - "Virgile Andreani", "Virgile", "Andreani", - "Vsevolod Velichko", "Vsevolod", "Velichko", - "Wiktor Kuropatwa", "Wiktor", "Kuropatwa", - "Yury Krivopalov", "Yury", "Krivopalov", - "anonymousknight", - "kwantam", - "nicoo", - "rivy", - // rust - "clippy", - "concat", - "fract", - "powi", - "println", - "repr", - "rfind", - "rustc", - "rustfmt", - "struct", - "structs", - "substr", - "splitn", - "trunc", - // shell - "passwd", - "pipefail", - "tcsh", - // tags - "Maint", - // uutils - "chcon", - "chgrp", - "chmod", - "chown", - "chroot", - "cksum", - "csplit", - "dircolors", - "hashsum", - "hostid", - "logname", - "mkdir", - "mkfifo", - "mknod", - "mktemp", - "nohup", - "nproc", - "numfmt", - "pathchk", - "printenv", - "printf", - "readlink", - "realpath", - "relpath", - "rmdir", - "runcon", - "shuf", - "stdbuf", - "stty", - "tsort", - "uname", - "unexpand", - "whoami", - // vars/errno - "errno", - "EOPNOTSUPP", - // vars/fcntl - "F_GETFL", - "GETFL", - "fcntl", - "vmsplice", - // vars/libc - "FILENO", - "HOSTSIZE", - "IDSIZE", - "IFIFO", - "IFREG", - "IRGRP", - "IROTH", - "IRUSR", - "ISGID", - "ISUID", - "ISVTX", - "IWGRP", - "IWOTH", - "IWUSR", - "IXGRP", - "IXOTH", - "IXUSR", - "LINESIZE", - "NAMESIZE", - "USERSIZE", - "addrinfo", - "addrlen", - "canonname", - "chroot", - "freeaddrinfo", - "getaddrinfo", - "getegid", - "geteuid", - "getgid", - "getgrgid", - "getgrnam", - "getgrouplist", - "getgroups", - "getpwnam", - "getpwuid", - "getuid", - "inode", - "isatty", - "lchown", - "setgid", - "setgroups", - "setuid", - "socktype", - "umask", - "waitpid", - // vars/nix - "iovec", - "unistd", - // vars/signals - "SIGPIPE", - // vars/sync - "Condvar", - // vars/stat - "fstat", - "stat", - // vars/time - "Timespec", - "nsec", - "nsecs", - "strftime", - "usec", - "usecs", - // vars/utmpx - "endutxent", - "getutxent", - "getutxid", - "getutxline", - "pututxline", - "setutxent", - "utmp", - "utmpx", - "utmpxname", - // vars/winapi - "errhandlingapi", - "fileapi", - "handleapi", - "lmcons", - "minwindef", - "processthreadsapi", - "synchapi", - "sysinfoapi", - "winbase", - "winerror", - "winnt", - "winsock", - "DWORD", - "LPWSTR", - "WCHAR", - // uucore - "optflag", - "optflagmulti", - "optflagopt", - "optmulti", - "optopt", - // uutils - "coreopts", - "coreutils", - "libc", - "libstdbuf", - "musl", - "ucmd", - "utmpx", - "uucore", - "uucore_procs", - "uumain", - "uutils" - ], - // words - list of words to be always considered correct - "words": [] + "version": "0.1", // Version of the setting file. Always 0.1 + "language": "en", // language - current active spelling language + "dictionaries": ["acronyms+names", "jargon", "people", "shell", "workspace"], + "dictionaryDefinitions": [ + { "name": "acronyms+names", "path": "./cspell.dictionaries/acronyms+names.wordlist.txt" }, + { "name": "jargon", "path": "./cspell.dictionaries/jargon.wordlist.txt" }, + { "name": "people", "path": "./cspell.dictionaries/people.wordlist.txt" }, + { "name": "shell", "path": "./cspell.dictionaries/shell.wordlist.txt" }, + { "name": "workspace", "path": "./cspell.dictionaries/workspace.wordlist.txt" } + ], + // ignorePaths - a list of globs to specify which files are to be ignored + "ignorePaths": ["Cargo.lock", "target/**", "tests/**/fixtures/**"], + // ignoreWords - a list of words to be ignored (even if they are in the flagWords) + "ignoreWords": [], + // words - list of words to be always considered correct + "words": [] } diff --git a/.vscode/cspell.dictionaries/acronyms+names.wordlist.txt b/.vscode/cspell.dictionaries/acronyms+names.wordlist.txt new file mode 100644 index 000000000..3956d1d8a --- /dev/null +++ b/.vscode/cspell.dictionaries/acronyms+names.wordlist.txt @@ -0,0 +1,64 @@ +# * abbreviations / acronyms +AIX +ASLR # address space layout randomization +AST # abstract syntax tree +CICD # continuous integration/deployment +CPU +CPUs +DevOps +Ext3 +FIFO +FIFOs +FQDN # fully qualified domain name +GID # group ID +GIDs +GNUEABI +GNUEABIhf +JFS +MSRV # minimum supported rust version +MSVC +NixOS +POSIX +POSIXLY +RISC +RISCV +RNG # random number generator +RNGs +ReiserFS +Solaris +UID # user ID +UIDs +UUID # universally unique identifier +WASI +WASM +XFS +aarch +flac +lzma + +# * names +BusyBox +BusyTest +Codacy +Cygwin +Deno +EditorConfig +FreeBSD +Gmail +Irix +MS-DOS +MSDOS +MacOS +MinGW +Minix +NetBSD +Novell +OpenBSD +POSIX +PowerPC +SELinux +SkyPack +Solaris +SysV +Xenix +Yargs diff --git a/.vscode/cspell.dictionaries/jargon.wordlist.txt b/.vscode/cspell.dictionaries/jargon.wordlist.txt new file mode 100644 index 000000000..89af1b153 --- /dev/null +++ b/.vscode/cspell.dictionaries/jargon.wordlist.txt @@ -0,0 +1,110 @@ +arity +autogenerate +autogenerated +autogenerates +bitmask +bitwise +bytewise +canonicalization +canonicalize +canonicalizing +colorizable +colorize +coprime +consts +cyclomatic +dedup +deduplication +demangle +denoland +deque +dequeue +dev +devs +discoverability +duplicative +enqueue +errored +executable +executables +exponentiate +eval +falsey +flamegraph +gibibytes +glob +globbing +hardfloat +hardlink +hardlinks +hasher +hashsums +kibi +kibibytes +mebi +mebibytes +mergeable +microbenchmark +microbenchmarks +microbenchmarking +multibyte +multicall +nonportable +nonprinting +peekable +performant +precompiled +precompute +preload +prepend +prepended +primality +pseudoprime +pseudoprimes +quantiles +readonly +reparse +seedable +semver +semiprime +semiprimes +shortcode +shortcodes +subcommand +subexpression +submodule +symlink +symlinks +syscall +syscalls +tokenize +truthy +unbuffered +unescape +unintuitive +unprefixed +unportable +unsync +whitespace +wordlist +wordlists + +# * abbreviations +consts +deps +dev +maint +proc +procs + +# * constants +xffff + +# * variables +delim +errno +progname +retval +subdir +val +vals diff --git a/.vscode/cspell.dictionaries/people.wordlist.txt b/.vscode/cspell.dictionaries/people.wordlist.txt new file mode 100644 index 000000000..01cfa4a3e --- /dev/null +++ b/.vscode/cspell.dictionaries/people.wordlist.txt @@ -0,0 +1,171 @@ +Akira Hayakawa + Akira + Hayakawa +Alan Andrade + Alan + Andrade +Aleksander Bielawski + Aleksander + Bielawski +Alex Lyon + Alex + Lyon +Alexander Batischev + Alexander + Batischev +Alexander Fomin + Alexander + Fomin +Anthony Deschamps + Anthony + Deschamps +Árni Dagur + Árni + Dagur +Ben Eills + Ben + Eills +Ben Hirsch + Ben + Hirsch +Benoit Benedetti + Benoit + Benedetti +Boden Garman + Boden + Garman +Chirag B Jadwani + Chirag + Jadwani +Derek Chiang + Derek + Chiang +Dorota Kapturkiewicz + Dorota + Kapturkiewicz +Evgeniy Klyuchikov + Evgeniy + Klyuchikov +Fangxu Hu + Fangxu + Hu +Gil Cottle + Gil + Cottle +Haitao Li + Haitao + Li +Inokentiy Babushkin + Inokentiy + Babushkin +Jeremiah Peschka + Jeremiah + Peschka +Jian Zeng + Jian + Zeng +Jimmy Lu + Jimmy + Lu +Joao Oliveira + Joao + Oliveira +Jordi Boggiano + Jordi + Boggiano +Jordy Dickinson + Jordy + Dickinson +Joseph Crail + Joseph + Crail +Joshua S Miller + Joshua + Miller +Konstantin Pospelov + Konstantin + Pospelov +Maciej Dziardziel + Maciej + Dziardziel +Martin Kysel + Martin + Kysel +Michael Debertol + Michael + Debertol +Michael Gehring + Michael + Gehring +Morten Olsen Lysgaard + Morten + Olsen + Lysgaard +Nicholas Juszczak + Nicholas + Juszczak +Nick Platt + Nick + Platt +Orvar Segerström + Orvar + Segerström +Peter Atashian + Peter + Atashian +Robert Swinford + Robert + Swinford +Rolf Morel + Rolf + Morel +Roman Gafiyatullin + Roman + Gafiyatullin +Roy Ivy III * rivy + Roy + Ivy + III + rivy +Sergey "Shnatsel" Davidoff + Sergey Shnatsel Davidoff + Sergey + Shnatsel + Davidoff +Sokovikov Evgeniy + Sokovikov + Evgeniy +Sunrin SHIMURA + Sunrin + SHIMURA +Sylvestre Ledru + Sylvestre + Ledru +T Jameson Little + Jameson + Little +Tobias Bohumir Schottdorf + Tobias + Bohumir + Schottdorf +Virgile Andreani + Virgile + Andreani +Vsevolod Velichko + Vsevolod + Velichko +Wiktor Kuropatwa + Wiktor + Kuropatwa +Yury Krivopalov + Yury + Krivopalov + +KokaKiwi +Mahkoh +Smigle00 + Smigle00 + Smigle +anonymousknight +kwantam +nicoo diff --git a/.vscode/cspell.dictionaries/shell.wordlist.txt b/.vscode/cspell.dictionaries/shell.wordlist.txt new file mode 100644 index 000000000..d8f297d21 --- /dev/null +++ b/.vscode/cspell.dictionaries/shell.wordlist.txt @@ -0,0 +1,93 @@ +# * Mac +clonefile + +# * POSIX +TMPDIR +adduser +csh +globstar +inotify +localtime +mountinfo +mountpoint +mtab +nullglob +passwd +pipefail +popd +ptmx +pushd +setarch +sh +sudo +sudoedit +tcsh +tzselect +urandom +wtmp +zsh + +# * Windows +APPDATA +COMSPEC +HKCU +HKLM +HOMEDRIVE +HOMEPATH +LOCALAPPDATA +PATHEXT +PATHEXT +SYSTEMROOT +USERDOMAIN +USERNAME +USERPROFILE +procmon + +# * `git` +gitattributes +gitignore + +# * `make` (`gmake`) +CURDIR +GNUMAKEFLAGS +GNUMakefile +LIBPATTERNS +MAKECMDGOALS +MAKEFILES +MAKEFLAGS +MAKELEVEL +MAKESHELL +SHELLSTATUS +VPATH +abspath +addprefix +addsuffix +endef +firstword +ifeq +ifneq +lastword +notdir +patsubst + + +# * `npm` +preversion + +# * utilities +cachegrind +chglog +codespell +commitlint +dprint +dtrace +gcov +gmake +grcov +grep +markdownlint +rerast +rollup +sed +wslpath +xargs diff --git a/.vscode/cspell.dictionaries/workspace.wordlist.txt b/.vscode/cspell.dictionaries/workspace.wordlist.txt new file mode 100644 index 000000000..b567a6c21 --- /dev/null +++ b/.vscode/cspell.dictionaries/workspace.wordlist.txt @@ -0,0 +1,295 @@ +# * cargo +cdylib +rlib + +# * crates +advapi +advapi32-sys +aho-corasick +backtrace +bstr +byteorder +chacha +chrono +conv +corasick +crossterm +filetime +formatteriteminfo +fsext +getopts +getrandom +globset +itertools +lscolors +memchr +multifilereader +onig +ouroboros +peekreader +quickcheck +rand_chacha +ringbuffer +smallvec +tempdir +tempfile +termion +termios +termsize +termwidth +textwrap +thiserror +walkdir +winapi +xattr + +# * rust/rustc +RUSTDOCFLAGS +RUSTFLAGS +bitxor # BitXor trait function +clippy +concat +fract +powi +println +repr +rfind +rustc +rustfmt +struct +structs +substr +splitn +trunc + +# * uutils +chcon +chgrp +chmod +chown +chroot +cksum +csplit +dircolors +hashsum +hostid +logname +mkdir +mkfifo +mknod +mktemp +nohup +nproc +numfmt +pathchk +printenv +printf +readlink +realpath +relpath +rmdir +runcon +shuf +sprintf +stdbuf +stty +tsort +uname +unexpand +whoami + +# * vars/errno +errno +EEXIST +ENOENT +ENOSYS +EPERM +EOPNOTSUPP + +# * vars/fcntl +F_GETFL + GETFL +fcntl +vmsplice + +# * vars/libc +FILENO +HOSTSIZE +IDSIZE +IFBLK +IFCHR +IFDIR +IFIFO +IFLNK +IFMT +IFREG +IFSOCK +IRGRP +IROTH +IRUSR +ISGID +ISUID +ISVTX +IWGRP +IWOTH +IWUSR +IXGRP +IXOTH +IXUSR +LINESIZE +NAMESIZE +RTLD_NEXT + RTLD +SIGINT +SIGKILL +SIGTERM +SYS_fdatasync +SYS_syncfs +USERSIZE +addrinfo +addrlen +blocksize +canonname +chroot +dlsym +fdatasync +freeaddrinfo +getaddrinfo +getegid +geteuid +getgid +getgrgid +getgrnam +getgrouplist +getgroups +getpwnam +getpwuid +getuid +inode +inodes +isatty +lchown +setgid +setgroups +settime +setuid +socktype +statfs +statvfs +strcmp +strerror +syncfs +umask +waitpid +wcslen + +# * vars/nix +iovec +unistd + +# * vars/signals +SIGPIPE + +# * vars/std +CString +pathbuf + +# * vars/stat +bavail +bfree +bsize +ffree +frsize +fsid +fstat +fstype +namelen +# unix::fs::MetadataExt +atime # access time +blksize # blocksize for file system I/O +blocks # number of blocks allocated to file +ctime # creation time +dev # ID of device containing the file +gid # group ID of file owner +ino # inode number +mode # permissions +mtime # modification time +nlink # number of hard links to file +rdev # device ID if file is a character/block special file +size # total size of file in bytes +uid # user ID of file owner +nsec # nanosecond measurement scale +# freebsd::MetadataExt +iosize + +# * vars/time +Timespec +isdst +nanos +nsec +nsecs +strftime +strptime +subsec +usec +usecs +utcoff + +# * vars/utmpx +endutxent +getutxent +getutxid +getutxline +pututxline +setutxent +utmp +utmpx +utmpxname + +# * vars/winapi +DWORD +SYSTEMTIME +LPVOID +LPWSTR +ULONG +ULONGLONG +UNLEN +WCHAR +errhandlingapi +fileapi +handleapi +lmcons +minwinbase +minwindef +processthreadsapi +synchapi +sysinfoapi +winbase +winerror +winnt +winsock + +# * vars/uucore +optflag +optflagmulti +optflagopt +optmulti +optopt + +# * uutils +ccmd +coreopts +coreutils +keepenv +libc +libstdbuf +musl +tmpd +ucmd +ucommand +utmpx +uucore +uucore_procs +uumain +uutil +uutils diff --git a/.vscode/extensions.json b/.vscode/extensions.json index cb28d8883..46b105d37 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,10 +1,12 @@ { - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format + // spell-checker:ignore (misc) matklad + // see for the documentation about the extensions.json format "recommendations": [ // Rust language support. "rust-lang.rust", // Provides support for rust-analyzer: novel LSP server for the Rust programming language. - "matklad.rust-analyzer" + "matklad.rust-analyzer", + // `cspell` spell-checker support + "streetsidesoftware.code-spell-checker" ] } diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 6c50b811d..d196c6e95 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -5,7 +5,7 @@ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, +identity and expression, level of experience, education, socioeconomic status, nationality, personal appearance, race, religion, or sexual identity and orientation. diff --git a/DEVELOPER_INSTRUCTIONS.md b/DEVELOPER_INSTRUCTIONS.md index 3aa8b5b12..e0a5cf001 100644 --- a/DEVELOPER_INSTRUCTIONS.md +++ b/DEVELOPER_INSTRUCTIONS.md @@ -1,6 +1,8 @@ Code Coverage Report Generation --------------------------------- + + Code coverage report can be generated using [grcov](https://github.com/mozilla/grcov). ### Using Nightly Rust @@ -17,7 +19,7 @@ $ grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-exist $ # open target/debug/coverage/index.html in browser ``` -if changes are not reflected in the report then run `cargo clean` and run the above commands. +if changes are not reflected in the report then run `cargo clean` and run the above commands. ### Using Stable Rust diff --git a/GNUmakefile b/GNUmakefile index 409a527cd..b6a4e5c56 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,3 +1,5 @@ +# spell-checker:ignore (misc) testsuite runtest (targets) busytest distclean manpages pkgs ; (vars/env) BINDIR BUILDDIR CARGOFLAGS DESTDIR DOCSDIR INSTALLDIR INSTALLEES MANDIR MULTICALL + # Config options PROFILE ?= debug MULTICALL ?= n @@ -274,7 +276,7 @@ busybox-src: $(BUILDDIR)/.config: $(BASEDIR)/.busybox-config cp $< $@ -# Test under the busybox testsuite +# Test under the busybox test suite $(BUILDDIR)/busybox: busybox-src build-coreutils $(BUILDDIR)/.config cp $(BUILDDIR)/coreutils $(BUILDDIR)/busybox; \ chmod +x $@; diff --git a/Makefile b/Makefile index 044aaa770..f56df90fb 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -USEGNU=gmake $* +UseGNU=gmake $* all: - @$(USEGNU) + @$(UseGNU) .DEFAULT: - @$(USEGNU) + @$(UseGNU) diff --git a/README.md b/README.md index 1365bf7ce..e6aaa71a6 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ ----------------------------------------------- - + uutils is an attempt at writing universal (as in cross-platform) CLI utilities in [Rust](http://www.rust-lang.org). This repository is intended to @@ -300,13 +300,13 @@ $ make UTILS='UTILITY_1 UTILITY_2' SPEC=y test This testing functionality is only available on *nix operating systems and requires `make`. -To run busybox's tests for all utilities for which busybox has tests +To run busybox tests for all utilities for which busybox has tests ```bash $ make busytest ``` -To run busybox's tests for a few of the available utilities +To run busybox tests for a few of the available utilities ```bash $ make UTILS='UTILITY_1 UTILITY_2' busytest @@ -323,6 +323,7 @@ $ make UTILS='UTILITY_1 UTILITY_2' RUNTEST_ARGS='-v' busytest ![Evolution over time](https://github.com/uutils/coreutils-tracking/blob/main/gnu-results.png?raw=true) To run locally: + ```bash $ bash util/build-gnu.sh $ bash util/run-gnu-test.sh diff --git a/docs/GNUmakefile b/docs/GNUmakefile index 894a53be0..49d827da8 100644 --- a/docs/GNUmakefile +++ b/docs/GNUmakefile @@ -1,5 +1,6 @@ +# spell-checker:ignore (vars/env) SPHINXOPTS SPHINXBUILD SPHINXPROJ SOURCEDIR BUILDDIR + # Minimal makefile for Sphinx documentation -# # You can set these variables from the command line. SPHINXOPTS = diff --git a/docs/Makefile b/docs/Makefile index 044aaa770..f56df90fb 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,5 +1,5 @@ -USEGNU=gmake $* +UseGNU=gmake $* all: - @$(USEGNU) + @$(UseGNU) .DEFAULT: - @$(USEGNU) + @$(UseGNU) diff --git a/docs/compiles_table.py b/docs/compiles_table.py index a051287c9..aa1b8703c 100644 --- a/docs/compiles_table.py +++ b/docs/compiles_table.py @@ -10,6 +10,8 @@ from pathlib import Path # third party dependencies from tqdm import tqdm +# spell-checker:ignore (libs) tqdm imap ; (shell/mac) xcrun ; (vars) nargs + BINS_PATH=Path("../src/uu") CACHE_PATH=Path("compiles_table.csv") TARGETS = [ @@ -50,7 +52,7 @@ TARGETS = [ class Target(str): def __new__(cls, content): obj = super().__new__(cls, content) - obj.arch, obj.platfrom, obj.os = Target.parse(content) + obj.arch, obj.platform, obj.os = Target.parse(content) return obj @staticmethod diff --git a/docs/conf.py b/docs/conf.py index 74e5e1fb8..5a1213627 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -21,6 +21,8 @@ # import sys # sys.path.insert(0, os.path.abspath('.')) +# spell-checker:ignore (words) howto htbp imgmath toctree todos uutilsdoc + import glob import os import re @@ -180,6 +182,6 @@ for name in glob.glob('*.rst'): # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'uutils', 'uutils Documentation', - author, 'uutils', 'A cross-platform reimplementation of GNU coreutils in Rust.', + author, 'uutils', 'A cross-platform implementation of GNU coreutils, written in Rust.', 'Miscellaneous'), ] diff --git a/docs/index.rst b/docs/index.rst index 4d70d4368..7f782b12a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -3,8 +3,11 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Welcome to uutils's documentation! -================================== +.. + spell-checker:ignore (directives) genindex maxdepth modindex toctree ; (misc) quickstart + +Welcome to uutils' documentation! +================================= .. toctree:: :maxdepth: 2 diff --git a/docs/make.bat b/docs/make.bat index 1e8ea10a0..6e63e3baa 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -1,5 +1,8 @@ +@setLocal @ECHO OFF +rem spell-checker:ignore (vars/env) BUILDDIR SOURCEDIR SPHINXBUILD SPHINXOPTS SPHINXPROJ + pushd %~dp0 REM Command file for Sphinx documentation @@ -14,7 +17,7 @@ set SPHINXPROJ=uutils if "%1" == "" goto help %SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( +if ErrorLevel 9009 ( echo. echo.The 'sphinx-build' command was not found. Make sure you have Sphinx echo.installed, then set the SPHINXBUILD environment variable to point diff --git a/src/bin/coreutils.rs b/src/bin/coreutils.rs index 7fc494020..2e703b682 100644 --- a/src/bin/coreutils.rs +++ b/src/bin/coreutils.rs @@ -58,7 +58,7 @@ fn main() { // binary name equals prefixed util name? // * prefix/stem may be any string ending in a non-alphanumeric character - let utilname = if let Some(util) = utils.keys().find(|util| { + let util_name = if let Some(util) = utils.keys().find(|util| { binary_as_util.ends_with(*util) && !(&binary_as_util[..binary_as_util.len() - (*util).len()]) .ends_with(char::is_alphanumeric) @@ -71,7 +71,7 @@ fn main() { }; // 0th argument equals util name? - if let Some(util_os) = utilname { + if let Some(util_os) = util_name { let util = util_os.as_os_str().to_string_lossy(); match utils.get(&util[..]) { diff --git a/src/uu/arch/src/main.rs b/src/uu/arch/src/main.rs index 43e0af5bf..e2668864c 100644 --- a/src/uu/arch/src/main.rs +++ b/src/uu/arch/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_arch); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_arch); diff --git a/src/uu/base32/src/main.rs b/src/uu/base32/src/main.rs index b59cb89f0..83a0b6607 100644 --- a/src/uu/base32/src/main.rs +++ b/src/uu/base32/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_base32); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_base32); diff --git a/src/uu/base64/src/main.rs b/src/uu/base64/src/main.rs index 07ed34256..cae6cb3c4 100644 --- a/src/uu/base64/src/main.rs +++ b/src/uu/base64/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_base64); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_base64); diff --git a/src/uu/basename/src/main.rs b/src/uu/basename/src/main.rs index d1aa19f2b..aa452f750 100644 --- a/src/uu/basename/src/main.rs +++ b/src/uu/basename/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_basename); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_basename); diff --git a/src/uu/cat/src/main.rs b/src/uu/cat/src/main.rs index 2b7969473..1adab666b 100644 --- a/src/uu/cat/src/main.rs +++ b/src/uu/cat/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_cat); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_cat); diff --git a/src/uu/cat/src/splice.rs b/src/uu/cat/src/splice.rs index bd6be60f1..0b46fc662 100644 --- a/src/uu/cat/src/splice.rs +++ b/src/uu/cat/src/splice.rs @@ -9,7 +9,7 @@ const BUF_SIZE: usize = 1024 * 16; /// This function is called from `write_fast()` on Linux and Android. The /// function `splice()` is used to move data between two file descriptors -/// without copying between kernel- and userspace. This results in a large +/// without copying between kernel and user spaces. This results in a large /// speedup. /// /// The `bool` in the result value indicates if we need to fall back to normal diff --git a/src/uu/chgrp/src/main.rs b/src/uu/chgrp/src/main.rs index 2faba7ba4..ee6f70a8b 100644 --- a/src/uu/chgrp/src/main.rs +++ b/src/uu/chgrp/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_chgrp); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_chgrp); diff --git a/src/uu/chmod/src/chmod.rs b/src/uu/chmod/src/chmod.rs index c4bf309d6..62faacffe 100644 --- a/src/uu/chmod/src/chmod.rs +++ b/src/uu/chmod/src/chmod.rs @@ -112,7 +112,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { Arg::with_name(options::MODE) .required_unless(options::REFERENCE) .takes_value(true), - // It would be nice if clap could parse with delimeter, e.g. "g-x,u+x", + // It would be nice if clap could parse with delimiter, e.g. "g-x,u+x", // however .multiple(true) cannot be used here because FILE already needs that. // Only one positional argument with .multiple(true) set is allowed per command ) diff --git a/src/uu/chmod/src/main.rs b/src/uu/chmod/src/main.rs index 604bd9a7d..adaf887f8 100644 --- a/src/uu/chmod/src/main.rs +++ b/src/uu/chmod/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_chmod); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_chmod); diff --git a/src/uu/chown/src/main.rs b/src/uu/chown/src/main.rs index ee5aeeba0..b3ed39970 100644 --- a/src/uu/chown/src/main.rs +++ b/src/uu/chown/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_chown); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_chown); diff --git a/src/uu/chroot/src/main.rs b/src/uu/chroot/src/main.rs index a177c9301..0ca88cfaf 100644 --- a/src/uu/chroot/src/main.rs +++ b/src/uu/chroot/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_chroot); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_chroot); diff --git a/src/uu/cksum/src/cksum.rs b/src/uu/cksum/src/cksum.rs index 1d45c1332..b6f798d5e 100644 --- a/src/uu/cksum/src/cksum.rs +++ b/src/uu/cksum/src/cksum.rs @@ -99,15 +99,15 @@ const fn crc_entry(input: u8) -> u32 { // i += 1; //} unroll!(8, |_i| { - let if_cond = crc & 0x8000_0000; + let if_condition = crc & 0x8000_0000; let if_body = (crc << 1) ^ 0x04c1_1db7; let else_body = crc << 1; // NOTE: i feel like this is easier to understand than emulating an if statement in bitwise // ops - let cond_table = [else_body, if_body]; + let condition_table = [else_body, if_body]; - crc = cond_table[(if_cond != 0) as usize]; + crc = condition_table[(if_condition != 0) as usize]; }); crc diff --git a/src/uu/cksum/src/main.rs b/src/uu/cksum/src/main.rs index 50f424f41..b8a8f6b33 100644 --- a/src/uu/cksum/src/main.rs +++ b/src/uu/cksum/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_cksum); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_cksum); diff --git a/src/uu/comm/src/main.rs b/src/uu/comm/src/main.rs index 149098c3c..07ac07544 100644 --- a/src/uu/comm/src/main.rs +++ b/src/uu/comm/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_comm); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_comm); diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 4d9e5965e..b7c64928f 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1335,7 +1335,7 @@ fn copy_on_write_macos(source: &Path, dest: &Path, mode: ReflinkMode) -> CopyRes } if raw_pfn.is_null() || error != 0 { - // clonefile(2) is not supported or it error'ed out (possibly because the FS does not + // clonefile(2) is either not supported or it errored out (possibly because the FS does not // support COW). match mode { ReflinkMode::Always => { diff --git a/src/uu/cp/src/main.rs b/src/uu/cp/src/main.rs index 425d490e7..acfcfd1b2 100644 --- a/src/uu/cp/src/main.rs +++ b/src/uu/cp/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_cp); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_cp); diff --git a/src/uu/csplit/src/csplit.rs b/src/uu/csplit/src/csplit.rs index 43f95fff5..a2eb8604a 100644 --- a/src/uu/csplit/src/csplit.rs +++ b/src/uu/csplit/src/csplit.rs @@ -13,10 +13,10 @@ use std::{ mod csplit_error; mod patterns; -mod splitname; +mod split_name; use crate::csplit_error::CsplitError; -use crate::splitname::SplitName; +use crate::split_name::SplitName; use uucore::InvalidEncodingHandling; static VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -77,7 +77,7 @@ impl CsplitOptions { /// # Errors /// /// - [`io::Error`] if there is some problem reading/writing from/to a file. -/// - [`::CsplitError::LineOutOfRange`] if the linenum pattern is larger than the number of input +/// - [`::CsplitError::LineOutOfRange`] if the line number pattern is larger than the number of input /// lines. /// - [`::CsplitError::LineOutOfRangeOnRepetition`], like previous but after applying the pattern /// more than once. diff --git a/src/uu/csplit/src/main.rs b/src/uu/csplit/src/main.rs index 97aeb3821..b0b144e8c 100644 --- a/src/uu/csplit/src/main.rs +++ b/src/uu/csplit/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_csplit); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_csplit); diff --git a/src/uu/csplit/src/patterns.rs b/src/uu/csplit/src/patterns.rs index d2f14578a..5621d18a3 100644 --- a/src/uu/csplit/src/patterns.rs +++ b/src/uu/csplit/src/patterns.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (regex) SKIPTO UPTO ; (vars) ntimes + use crate::csplit_error::CsplitError; use regex::Regex; @@ -167,7 +169,7 @@ fn validate_line_numbers(patterns: &[Pattern]) -> Result<(), CsplitError> { .try_fold(0, |prev_ln, ¤t_ln| match (prev_ln, current_ln) { // a line number cannot be zero (_, 0) => Err(CsplitError::LineNumberIsZero), - // two consecutifs numbers should not be equal + // two consecutive numbers should not be equal (n, m) if n == m => { show_warning!("line number '{}' is the same as preceding line number", n); Ok(n) diff --git a/src/uu/csplit/src/splitname.rs b/src/uu/csplit/src/split_name.rs similarity index 98% rename from src/uu/csplit/src/splitname.rs rename to src/uu/csplit/src/split_name.rs index 66b17ba67..6db781e9b 100644 --- a/src/uu/csplit/src/splitname.rs +++ b/src/uu/csplit/src/split_name.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (regex) diuox + use regex::Regex; use crate::csplit_error::CsplitError; @@ -225,6 +227,8 @@ impl SplitName { #[cfg(test)] mod tests { + // spell-checker:ignore (path) xxcst + use super::*; #[test] @@ -319,13 +323,13 @@ mod tests { } #[test] - fn zero_padding_lower_hexa() { + fn zero_padding_lower_hex() { let split_name = SplitName::new(None, Some(String::from("cst-%03x-")), None).unwrap(); assert_eq!(split_name.get(42), "xxcst-02a-"); } #[test] - fn zero_padding_upper_hexa() { + fn zero_padding_upper_hex() { let split_name = SplitName::new(None, Some(String::from("cst-%03X-")), None).unwrap(); assert_eq!(split_name.get(42), "xxcst-02A-"); } @@ -337,13 +341,13 @@ mod tests { } #[test] - fn alternate_form_lower_hexa() { + fn alternate_form_lower_hex() { let split_name = SplitName::new(None, Some(String::from("cst-%#10x-")), None).unwrap(); assert_eq!(split_name.get(42), "xxcst- 0x2a-"); } #[test] - fn alternate_form_upper_hexa() { + fn alternate_form_upper_hex() { let split_name = SplitName::new(None, Some(String::from("cst-%#10X-")), None).unwrap(); assert_eq!(split_name.get(42), "xxcst- 0x2A-"); } @@ -373,13 +377,13 @@ mod tests { } #[test] - fn left_adjusted_lower_hexa() { + fn left_adjusted_lower_hex() { let split_name = SplitName::new(None, Some(String::from("cst-%-10x-")), None).unwrap(); assert_eq!(split_name.get(42), "xxcst-0x2a -"); } #[test] - fn left_adjusted_upper_hexa() { + fn left_adjusted_upper_hex() { let split_name = SplitName::new(None, Some(String::from("cst-%-10X-")), None).unwrap(); assert_eq!(split_name.get(42), "xxcst-0x2A -"); } diff --git a/src/uu/cut/src/main.rs b/src/uu/cut/src/main.rs index 065a01f40..8822335f6 100644 --- a/src/uu/cut/src/main.rs +++ b/src/uu/cut/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_cut); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_cut); diff --git a/src/uu/date/usage.txt b/src/uu/date/date-usage.mkd similarity index 97% rename from src/uu/date/usage.txt rename to src/uu/date/date-usage.mkd index 12df1a03c..829001095 100644 --- a/src/uu/date/usage.txt +++ b/src/uu/date/date-usage.mkd @@ -1,3 +1,8 @@ +# `date` usage + + + +``` text FORMAT controls the output. Interpreted sequences are: %% a literal % @@ -70,3 +75,4 @@ Show the time on the west coast of the US (use tzselect(1) to find TZ) Show the local time for 9AM next Friday on the west coast of the US $ date --date='TZ="America/Los_Angeles" 09:00 next Fri' +``` diff --git a/src/uu/date/src/date.rs b/src/uu/date/src/date.rs index 1fe80c03f..02aa7a60d 100644 --- a/src/uu/date/src/date.rs +++ b/src/uu/date/src/date.rs @@ -6,8 +6,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (format) MMDDhhmm -// spell-checker:ignore (ToDO) DATEFILE +// spell-checker:ignore (chrono) Datelike Timelike ; (format) DATEFILE MMDDhhmm ; (vars) datetime datetimes #[macro_use] extern crate uucore; diff --git a/src/uu/date/src/main.rs b/src/uu/date/src/main.rs index 13edc0fba..9064c7f67 100644 --- a/src/uu/date/src/main.rs +++ b/src/uu/date/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_date); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_date); diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index 8219b0a27..07f8b0214 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -6,9 +6,6 @@ // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. -// spell-checker:ignore (ToDO) mountinfo BLOCKSIZE fobj mptr noatime Iused overmounted -// spell-checker:ignore (libc/fs) asyncreads asyncwrites autofs bavail bfree bsize charspare cifs debugfs devfs devpts ffree frsize fsid fstypename fusectl inode inodes iosize kernfs mntbufp mntfromname mntonname mqueue namemax pipefs smbfs statvfs subfs syncreads syncwrites sysfs wcslen - #[macro_use] extern crate uucore; #[cfg(unix)] @@ -78,7 +75,7 @@ struct Options { #[derive(Debug, Clone)] struct Filesystem { - mountinfo: MountInfo, + mount_info: MountInfo, usage: FsUsage, } @@ -131,19 +128,19 @@ impl Options { } impl Filesystem { - // TODO: resolve uuid in `mountinfo.dev_name` if exists - fn new(mountinfo: MountInfo) -> Option { - let _stat_path = if !mountinfo.mount_dir.is_empty() { - mountinfo.mount_dir.clone() + // TODO: resolve uuid in `mount_info.dev_name` if exists + fn new(mount_info: MountInfo) -> Option { + let _stat_path = if !mount_info.mount_dir.is_empty() { + mount_info.mount_dir.clone() } else { #[cfg(unix)] { - mountinfo.dev_name.clone() + mount_info.dev_name.clone() } #[cfg(windows)] { // On windows, we expect the volume id - mountinfo.dev_id.clone() + mount_info.dev_id.clone() } }; #[cfg(unix)] @@ -154,14 +151,14 @@ impl Filesystem { None } else { Some(Filesystem { - mountinfo, + mount_info, usage: FsUsage::new(statvfs), }) } } #[cfg(windows)] Some(Filesystem { - mountinfo, + mount_info, usage: FsUsage::new(Path::new(&_stat_path)), }) } @@ -205,7 +202,7 @@ fn filter_mount_list(vmi: Vec, paths: &[String], opt: &Options) -> Ve if (!mi.dev_name.starts_with('/') || seen.dev_name.starts_with('/')) // let points towards the root of the device win. && (!target_nearer_root || source_below_root) - // let an entry overmounted on a new device win... + // let an entry over-mounted on a new device win... && (seen.dev_name == mi.dev_name /* ... but only when matching an existing mnt point, to avoid problematic replacement when given @@ -431,6 +428,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { header.push("Type"); } header.extend_from_slice(&if opt.show_inode_instead { + // spell-checker:disable-next-line ["Inodes", "Iused", "IFree", "IUses%"] } else { [ @@ -462,9 +460,9 @@ pub fn uumain(args: impl uucore::Args) -> i32 { } println!(); for fs in fs_list.iter() { - print!("{0: <16} ", fs.mountinfo.dev_name); + print!("{0: <16} ", fs.mount_info.dev_name); if opt.show_fs_type { - print!("{0: <5} ", fs.mountinfo.fs_type); + print!("{0: <5} ", fs.mount_info.fs_type); } if opt.show_inode_instead { print!( @@ -508,7 +506,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { } print!("{0: >5} ", use_size(free_size, total_size)); } - print!("{0: <16}", fs.mountinfo.mount_dir); + print!("{0: <16}", fs.mount_info.mount_dir); println!(); } diff --git a/src/uu/df/src/main.rs b/src/uu/df/src/main.rs index 6062603db..a6d403782 100644 --- a/src/uu/df/src/main.rs +++ b/src/uu/df/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_df); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_df); diff --git a/src/uu/dircolors/src/main.rs b/src/uu/dircolors/src/main.rs index 10c96ecd9..a6a820bd9 100644 --- a/src/uu/dircolors/src/main.rs +++ b/src/uu/dircolors/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_dircolors); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_dircolors); diff --git a/src/uu/dirname/src/main.rs b/src/uu/dirname/src/main.rs index e4be3372a..bf923e86a 100644 --- a/src/uu/dirname/src/main.rs +++ b/src/uu/dirname/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_dirname); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_dirname); diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index 6bd4f23e4..0bc8b30c8 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -5,8 +5,6 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (ToDO) BLOCKSIZE inode inodes ment strs - #[macro_use] extern crate uucore; @@ -62,14 +60,13 @@ const VERSION: &str = env!("CARGO_PKG_VERSION"); const NAME: &str = "du"; const SUMMARY: &str = "estimate file space usage"; const LONG_HELP: &str = " - Display values are in units of the first available SIZE from - --block-size, and the DU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environ‐ - ment variables. Otherwise, units default to 1024 bytes (or 512 if - POSIXLY_CORRECT is set). +Display values are in units of the first available SIZE from --block-size, +and the DU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables. +Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set). - SIZE is an integer and optional unit (example: 10M is 10*1024*1024). - Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (pow‐ - ers of 1000). +SIZE is an integer and optional unit (example: 10M is 10*1024*1024). +Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB,... (powers +of 1000). "; // TODO: Support Z & Y (currently limited by size of u64) @@ -588,7 +585,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { separate_dirs: matches.is_present(options::SEPARATE_DIRS), }; - let strs = match matches.value_of(options::FILE) { + let files = match matches.value_of(options::FILE) { Some(_) => matches.values_of(options::FILE).unwrap().collect(), None => { vec!["./"] // TODO: gnu `du` doesn't use trailing "/" here @@ -646,8 +643,8 @@ Try '{} --help' for more information.", }; let mut grand_total = 0; - for path_str in strs { - let path = PathBuf::from(&path_str); + for path_string in files { + let path = PathBuf::from(&path_string); match Stat::new(path) { Ok(stat) => { let mut inodes: HashSet = HashSet::new(); @@ -709,13 +706,13 @@ Try '{} --help' for more information.", } if options.total && index == (len - 1) { // The last element will be the total size of the the path under - // path_str. We add it to the grand total. + // path_string. We add it to the grand total. grand_total += size; } } } Err(_) => { - show_error!("{}: {}", path_str, "No such file or directory"); + show_error!("{}: {}", path_string, "No such file or directory"); } } } diff --git a/src/uu/du/src/main.rs b/src/uu/du/src/main.rs index de1967bc8..de9bfc1a5 100644 --- a/src/uu/du/src/main.rs +++ b/src/uu/du/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_du); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_du); diff --git a/src/uu/echo/src/main.rs b/src/uu/echo/src/main.rs index 00b84e983..b8d3b4b32 100644 --- a/src/uu/echo/src/main.rs +++ b/src/uu/echo/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_echo); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_echo); diff --git a/src/uu/env/src/env.rs b/src/uu/env/src/env.rs index 83927b160..50a327260 100644 --- a/src/uu/env/src/env.rs +++ b/src/uu/env/src/env.rs @@ -7,7 +7,7 @@ /* last synced with: env (GNU coreutils) 8.13 */ -// spell-checker:ignore (ToDO) execvp progname subcommand subcommands unsets +// spell-checker:ignore (ToDO) chdir execvp progname subcommand subcommands unsets #[macro_use] extern crate clap; diff --git a/src/uu/env/src/main.rs b/src/uu/env/src/main.rs index 8b654eb00..9c19a3ab4 100644 --- a/src/uu/env/src/main.rs +++ b/src/uu/env/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_env); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_env); diff --git a/src/uu/expand/src/main.rs b/src/uu/expand/src/main.rs index d80b6090f..a154b36be 100644 --- a/src/uu/expand/src/main.rs +++ b/src/uu/expand/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_expand); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_expand); diff --git a/src/uu/expr/src/main.rs b/src/uu/expr/src/main.rs index 4268865df..6fdd6be14 100644 --- a/src/uu/expr/src/main.rs +++ b/src/uu/expr/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_expr); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_expr); diff --git a/src/uu/factor/BENCHMARKING.md b/src/uu/factor/BENCHMARKING.md index e174d62b7..6bf9cbf90 100644 --- a/src/uu/factor/BENCHMARKING.md +++ b/src/uu/factor/BENCHMARKING.md @@ -1,5 +1,7 @@ # Benchmarking `factor` + + The benchmarks for `factor` are located under `tests/benches/factor` and can be invoked with `cargo bench` in that directory. @@ -7,19 +9,19 @@ They are located outside the `uu_factor` crate, as they do not comply with the project's minimum supported Rust version, *i.e.* may require a newer version of `rustc`. - ## Microbenchmarking deterministic functions We currently use [`criterion`] to benchmark deterministic functions, such as `gcd` and `table::factor`. -However, µbenchmarks are by nature unstable: not only are they specific to +However, microbenchmarks are by nature unstable: not only are they specific to the hardware, operating system version, etc., but they are noisy and affected by other tasks on the system (browser, compile jobs, etc.), which can cause `criterion` to report spurious performance improvements and regressions. -This can be mitigated by getting as close to [idealised conditions][lemire] +This can be mitigated by getting as close to [idealized conditions][lemire] as possible: + - minimize the amount of computation and I/O running concurrently to the benchmark, *i.e.* close your browser and IM clients, don't compile at the same time, etc. ; @@ -27,64 +29,60 @@ as possible: - [isolate a **physical** core], set it to `nohz_full`, and pin the benchmark to it, so it won't be preempted in the middle of a measurement ; - disable ASLR by running `setarch -R cargo bench`, so we can compare results - across multiple executions. - + across multiple executions. [`criterion`]: https://bheisler.github.io/criterion.rs/book/index.html [lemire]: https://lemire.me/blog/2018/01/16/microbenchmarking-calls-for-idealized-conditions/ [isolate a **physical** core]: https://pyperf.readthedocs.io/en/latest/system.html#isolate-cpus-on-linux -[frequency stays constant]: XXXTODO +[frequency stays constant]: ... - -### Guidance for designing µbenchmarks +### Guidance for designing microbenchmarks *Note:* this guidance is specific to `factor` and takes its application domain -into account; do not expect it to generalise to other projects. It is based +into account; do not expect it to generalize to other projects. It is based on Daniel Lemire's [*Microbenchmarking calls for idealized conditions*][lemire], which I recommend reading if you want to add benchmarks to `factor`. -1. Select a small, self-contained, deterministic component +1. Select a small, self-contained, deterministic component `gcd` and `table::factor` are good example of such: - no I/O or access to external data structures ; - no call into other components ; - - behaviour is deterministic: no RNG, no concurrency, ... ; + - behavior is deterministic: no RNG, no concurrency, ... ; - the test's body is *fast* (~100ns for `gcd`, ~10µs for `factor::table`), so each sample takes a very short time, minimizing variability and maximizing the numbers of samples we can take in a given time. -2. Benchmarks are immutable (once merged in `uutils`) +2. Benchmarks are immutable (once merged in `uutils`) Modifying a benchmark means previously-collected values cannot meaningfully be compared, silently giving nonsensical results. If you must modify an existing benchmark, rename it. -3. Test common cases +3. Test common cases We are interested in overall performance, rather than specific edge-cases; - use **reproducibly-randomised inputs**, sampling from either all possible + use **reproducibly-randomized inputs**, sampling from either all possible input values or some subset of interest. -4. Use [`criterion`], `criterion::black_box`, ... +4. Use [`criterion`], `criterion::black_box`, ... `criterion` isn't perfect, but it is also much better than ad-hoc solutions in each benchmark. - ## Wishlist ### Configurable statistical estimators -`criterion` always uses the arithmetic average as estimator; in µbenchmarks, +`criterion` always uses the arithmetic average as estimator; in microbenchmarks, where the code under test is fully deterministic and the measurements are subject to additive, positive noise, [the minimum is more appropriate][lemire]. - ### CI & reproducible performance testing Measuring performance on real hardware is important, as it relates directly to what users of `factor` experience; however, such measurements are subject to the constraints of the real-world, and aren't perfectly reproducible. -Moreover, the mitigations for it (described above) aren't achievable in +Moreover, the mitigation for it (described above) isn't achievable in virtualized, multi-tenant environments such as CI. -Instead, we could run the µbenchmarks in a simulated CPU with [`cachegrind`], +Instead, we could run the microbenchmarks in a simulated CPU with [`cachegrind`], measure execution “time” in that model (in CI), and use it to detect and report performance improvements and regressions. @@ -93,19 +91,17 @@ performance improvements and regressions. [`cachegrind`]: https://www.valgrind.org/docs/manual/cg-manual.html [`iai`]: https://bheisler.github.io/criterion.rs/book/iai/iai.html - -### Comparing randomised implementations across multiple inputs +### Comparing randomized implementations across multiple inputs `factor` is a challenging target for system benchmarks as it combines two characteristics: -1. integer factoring algorithms are randomised, with large variance in +1. integer factoring algorithms are randomized, with large variance in execution time ; 2. various inputs also have large differences in factoring time, that corresponds to no natural, linear ordering of the inputs. - If (1) was untrue (i.e. if execution time wasn't random), we could faithfully compare 2 implementations (2 successive versions, or `uutils` and GNU) using a scatter plot, where each axis corresponds to the perf. of one implementation. diff --git a/src/uu/factor/build.rs b/src/uu/factor/build.rs index eff21ae2f..32640d61a 100644 --- a/src/uu/factor/build.rs +++ b/src/uu/factor/build.rs @@ -13,8 +13,6 @@ //! 2 has no multiplicative inverse mode 2^64 because 2 | 2^64, //! and in any case divisibility by two is trivial by checking the LSB. -// spell-checker:ignore (ToDO) invs newr newrp newtp outstr - #![cfg_attr(test, allow(dead_code))] use std::env::{self, args}; @@ -60,13 +58,13 @@ fn main() { let mut x = primes.next().unwrap(); for next in primes { // format the table - let outstr = format!("({}, {}, {}),", x, modular_inverse(x), std::u64::MAX / x); - if cols + outstr.len() > MAX_WIDTH { - write!(file, "\n {}", outstr).unwrap(); - cols = 4 + outstr.len(); + let output = format!("({}, {}, {}),", x, modular_inverse(x), std::u64::MAX / x); + if cols + output.len() > MAX_WIDTH { + write!(file, "\n {}", output).unwrap(); + cols = 4 + output.len(); } else { - write!(file, " {}", outstr).unwrap(); - cols += 1 + outstr.len(); + write!(file, " {}", output).unwrap(); + cols += 1 + output.len(); } x = next; @@ -81,7 +79,7 @@ fn main() { } #[test] -fn test_generator_isprime() { +fn test_generator_is_prime() { assert_eq!(Sieve::odd_primes.take(10_000).all(is_prime)); } @@ -106,5 +104,5 @@ const PREAMBLE: &str = r##"/* // re-run src/factor/gen_tables.rs. #[allow(clippy::unreadable_literal)] -pub const P_INVS_U64: &[(u64, u64, u64)] = &[ +pub const PRIME_INVERSIONS_U64: &[(u64, u64, u64)] = &[ "##; diff --git a/src/uu/factor/src/factor.rs b/src/uu/factor/src/factor.rs index b279de7fc..54ad0bdd4 100644 --- a/src/uu/factor/src/factor.rs +++ b/src/uu/factor/src/factor.rs @@ -17,6 +17,7 @@ type Exponent = u8; #[derive(Clone, Debug)] struct Decomposition(SmallVec<[(u64, Exponent); NUM_FACTORS_INLINE]>); +// spell-checker:ignore (names) Erdős–Kac * Erdős Kac // The number of factors to inline directly into a `Decomposition` object. // As a consequence of the Erdős–Kac theorem, the average number of prime factors // of integers < 10²⁵ ≃ 2⁸³ is 4, so we can use a slightly higher value. @@ -250,6 +251,7 @@ impl Distribution for Standard { let mut g = 1u64; let mut n = u64::MAX; + // spell-checker:ignore (names) Adam Kalai * Kalai's // Adam Kalai's algorithm for generating uniformly-distributed // integers and their factorization. // diff --git a/src/uu/factor/src/main.rs b/src/uu/factor/src/main.rs index b251716b5..4d8b281b6 100644 --- a/src/uu/factor/src/main.rs +++ b/src/uu/factor/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_factor); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_factor); diff --git a/src/uu/factor/src/miller_rabin.rs b/src/uu/factor/src/miller_rabin.rs index 2a3b7bdf1..ec6d81c0f 100644 --- a/src/uu/factor/src/miller_rabin.rs +++ b/src/uu/factor/src/miller_rabin.rs @@ -21,6 +21,7 @@ impl Basis for Montgomery { } impl Basis for Montgomery { + // spell-checker:ignore (names) Steve Worley // Small set of bases for the Miller-Rabin prime test, valid for all 32b integers; // discovered by Steve Worley on 2013-05-27, see miller-rabin.appspot.com #[allow(clippy::unreadable_literal)] @@ -121,8 +122,8 @@ mod tests { } fn odd_primes() -> impl Iterator { - use crate::table::{NEXT_PRIME, P_INVS_U64}; - P_INVS_U64 + use crate::table::{NEXT_PRIME, PRIME_INVERSIONS_U64}; + PRIME_INVERSIONS_U64 .iter() .map(|(p, _, _)| *p) .chain(iter::once(NEXT_PRIME)) diff --git a/src/uu/factor/src/numeric/gcd.rs b/src/uu/factor/src/numeric/gcd.rs index 36ad833a6..004ef1515 100644 --- a/src/uu/factor/src/numeric/gcd.rs +++ b/src/uu/factor/src/numeric/gcd.rs @@ -93,7 +93,7 @@ mod tests { gcd(a, gcd(b, c)) == gcd(gcd(a, b), c) } - fn scalar_mult(a: u64, b: u64, k: u64) -> bool { + fn scalar_multiplication(a: u64, b: u64, k: u64) -> bool { gcd(k * a, k * b) == k * gcd(a, b) } diff --git a/src/uu/factor/src/numeric/modular_inverse.rs b/src/uu/factor/src/numeric/modular_inverse.rs index 763ee90a0..e4827a3ee 100644 --- a/src/uu/factor/src/numeric/modular_inverse.rs +++ b/src/uu/factor/src/numeric/modular_inverse.rs @@ -16,11 +16,11 @@ pub(crate) fn modular_inverse(a: T) -> T { debug_assert!(a % (one + one) == one, "{:?} is not odd", a); let mut t = zero; - let mut newt = one; + let mut new_t = one; let mut r = zero; - let mut newr = a; + let mut new_r = a; - while newr != zero { + while new_r != zero { let quot = if r == zero { // special case when we're just starting out // This works because we know that @@ -28,15 +28,15 @@ pub(crate) fn modular_inverse(a: T) -> T { T::max_value() } else { r - } / newr; + } / new_r; - let newtp = t.wrapping_sub(".wrapping_mul(&newt)); - t = newt; - newt = newtp; + let new_tp = t.wrapping_sub(".wrapping_mul(&new_t)); + t = new_t; + new_t = new_tp; - let newrp = r.wrapping_sub(".wrapping_mul(&newr)); - r = newr; - newr = newrp; + let new_rp = r.wrapping_sub(".wrapping_mul(&new_r)); + r = new_r; + new_r = new_rp; } debug_assert_eq!(r, one); diff --git a/src/uu/factor/src/numeric/montgomery.rs b/src/uu/factor/src/numeric/montgomery.rs index 8c38464bc..485025d87 100644 --- a/src/uu/factor/src/numeric/montgomery.rs +++ b/src/uu/factor/src/numeric/montgomery.rs @@ -69,7 +69,7 @@ impl Montgomery { let t_bits = T::zero().count_zeros() as usize; debug_assert!(x < (self.n.as_double_width()) << t_bits); - // TODO: optimiiiiiiise + // TODO: optimize let Montgomery { a, n } = self; let m = T::from_double_width(x).wrapping_mul(a); let nm = (n.as_double_width()) * (m.as_double_width()); @@ -138,7 +138,7 @@ impl Arithmetic for Montgomery { r + self.n.wrapping_neg() }; - // Normalise to [0; n[ + // Normalize to [0; n[ let r = if r < self.n { r } else { r - self.n }; // Check that r (reduced back to the usual representation) equals @@ -200,7 +200,7 @@ mod tests { } parametrized_check!(test_add); - fn test_mult() { + fn test_multiplication() { for n in 0..100 { let n = 2 * n + 1; let m = Montgomery::::new(n); @@ -213,7 +213,7 @@ mod tests { } } } - parametrized_check!(test_mult); + parametrized_check!(test_multiplication); fn test_roundtrip() { for n in 0..100 { diff --git a/src/uu/factor/src/table.rs b/src/uu/factor/src/table.rs index 518d4f241..6d4047e49 100644 --- a/src/uu/factor/src/table.rs +++ b/src/uu/factor/src/table.rs @@ -13,7 +13,7 @@ use crate::Factors; include!(concat!(env!("OUT_DIR"), "/prime_table.rs")); pub fn factor(num: &mut u64, factors: &mut Factors) { - for &(prime, inv, ceil) in P_INVS_U64 { + for &(prime, inv, ceil) in PRIME_INVERSIONS_U64 { if *num == 1 { break; } @@ -45,7 +45,7 @@ pub fn factor(num: &mut u64, factors: &mut Factors) { pub const CHUNK_SIZE: usize = 8; pub fn factor_chunk(n_s: &mut [u64; CHUNK_SIZE], f_s: &mut [Factors; CHUNK_SIZE]) { - for &(prime, inv, ceil) in P_INVS_U64 { + for &(prime, inv, ceil) in PRIME_INVERSIONS_U64 { if n_s[0] == 1 && n_s[1] == 1 && n_s[2] == 1 && n_s[3] == 1 { break; } diff --git a/src/uu/false/src/main.rs b/src/uu/false/src/main.rs index 0cede3b5e..382a16fc7 100644 --- a/src/uu/false/src/main.rs +++ b/src/uu/false/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_false); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_false); diff --git a/src/uu/fmt/src/main.rs b/src/uu/fmt/src/main.rs index d7e883ba7..35531a8b4 100644 --- a/src/uu/fmt/src/main.rs +++ b/src/uu/fmt/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_fmt); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_fmt); diff --git a/src/uu/fold/src/main.rs b/src/uu/fold/src/main.rs index abdf80211..1802f2cf8 100644 --- a/src/uu/fold/src/main.rs +++ b/src/uu/fold/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_fold); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_fold); diff --git a/src/uu/groups/src/main.rs b/src/uu/groups/src/main.rs index 0a37ec7f4..6efe64b54 100644 --- a/src/uu/groups/src/main.rs +++ b/src/uu/groups/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_groups); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_groups); diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index b1ba3c217..b39b5788c 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -370,7 +370,7 @@ pub fn uumain(mut args: impl uucore::Args) -> i32 { ); if !is_custom_binary(&binary_name) { - let algos = &[ + let algorithms = &[ ("md5", "work with MD5"), ("sha1", "work with SHA1"), ("sha224", "work with SHA224"), @@ -393,7 +393,7 @@ pub fn uumain(mut args: impl uucore::Args) -> i32 { ("b2sum", "work with BLAKE2"), ]; - for (name, desc) in algos { + for (name, desc) in algorithms { app = app.arg(Arg::with_name(name).long(name).help(desc)); } } diff --git a/src/uu/hashsum/src/main.rs b/src/uu/hashsum/src/main.rs index 12bd3b393..bc4e2f3be 100644 --- a/src/uu/hashsum/src/main.rs +++ b/src/uu/hashsum/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_hashsum); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_hashsum); diff --git a/src/uu/head/src/head.rs b/src/uu/head/src/head.rs index 3602b4a73..ff5ef2355 100644 --- a/src/uu/head/src/head.rs +++ b/src/uu/head/src/head.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (vars) zlines + use clap::{App, Arg}; use std::convert::TryFrom; use std::ffi::OsString; @@ -210,7 +212,7 @@ impl Default for HeadOptions { } } -fn rbuf_n_bytes(input: R, n: usize) -> std::io::Result<()> +fn read_n_bytes(input: R, n: usize) -> std::io::Result<()> where R: Read, { @@ -226,7 +228,7 @@ where Ok(()) } -fn rbuf_n_lines(input: &mut impl std::io::BufRead, n: usize, zero: bool) -> std::io::Result<()> { +fn read_n_lines(input: &mut impl std::io::BufRead, n: usize, zero: bool) -> std::io::Result<()> { if n == 0 { return Ok(()); } @@ -249,18 +251,18 @@ fn rbuf_n_lines(input: &mut impl std::io::BufRead, n: usize, zero: bool) -> std: }) } -fn rbuf_but_last_n_bytes(input: &mut impl std::io::BufRead, n: usize) -> std::io::Result<()> { +fn read_but_last_n_bytes(input: &mut impl std::io::BufRead, n: usize) -> std::io::Result<()> { if n == 0 { //prints everything - return rbuf_n_bytes(input, std::usize::MAX); + return read_n_bytes(input, std::usize::MAX); } let stdout = std::io::stdout(); let mut stdout = stdout.lock(); - let mut ringbuf = vec![0u8; n]; + let mut ring_buffer = vec![0u8; n]; // first we fill the ring buffer - if let Err(e) = input.read_exact(&mut ringbuf) { + if let Err(e) = input.read_exact(&mut ring_buffer) { if e.kind() == ErrorKind::UnexpectedEof { return Ok(()); } else { @@ -281,22 +283,22 @@ fn rbuf_but_last_n_bytes(input: &mut impl std::io::BufRead, n: usize) -> std::io if read == 0 { return Ok(()); } else if read >= n { - stdout.write_all(&ringbuf)?; + stdout.write_all(&ring_buffer)?; stdout.write_all(&buffer[..read - n])?; for i in 0..n { - ringbuf[i] = buffer[read - n + i]; + ring_buffer[i] = buffer[read - n + i]; } } else { - stdout.write_all(&ringbuf[..read])?; + stdout.write_all(&ring_buffer[..read])?; for i in 0..n - read { - ringbuf[i] = ringbuf[read + i]; + ring_buffer[i] = ring_buffer[read + i]; } - ringbuf[n - read..].copy_from_slice(&buffer[..read]); + ring_buffer[n - read..].copy_from_slice(&buffer[..read]); } } } -fn rbuf_but_last_n_lines( +fn read_but_last_n_lines( input: impl std::io::BufRead, n: usize, zero: bool, @@ -325,7 +327,7 @@ fn head_backwards_file(input: &mut std::fs::File, options: &HeadOptions) -> std: return Ok(()); } else { input.seek(SeekFrom::Start(0))?; - rbuf_n_bytes( + read_n_bytes( &mut std::io::BufReader::with_capacity(BUF_SIZE, input), size - n, )?; @@ -364,7 +366,7 @@ fn head_backwards_file(input: &mut std::fs::File, options: &HeadOptions) -> std: } }; input.seek(SeekFrom::Start(0))?; - rbuf_n_bytes( + read_n_bytes( &mut std::io::BufReader::with_capacity(BUF_SIZE, input), size - found, )?; @@ -379,9 +381,9 @@ fn head_file(input: &mut std::fs::File, options: &HeadOptions) -> std::io::Resul } else { match options.mode { Modes::Bytes(n) => { - rbuf_n_bytes(&mut std::io::BufReader::with_capacity(BUF_SIZE, input), n) + read_n_bytes(&mut std::io::BufReader::with_capacity(BUF_SIZE, input), n) } - Modes::Lines(n) => rbuf_n_lines( + Modes::Lines(n) => read_n_lines( &mut std::io::BufReader::with_capacity(BUF_SIZE, input), n, options.zeroed, @@ -393,8 +395,8 @@ fn head_file(input: &mut std::fs::File, options: &HeadOptions) -> std::io::Resul fn uu_head(options: &HeadOptions) -> Result<(), u32> { let mut error_count = 0; let mut first = true; - for fname in &options.files { - let res = match fname.as_str() { + for file in &options.files { + let res = match file.as_str() { "-" => { if (options.files.len() > 1 && !options.quiet) || options.verbose { if !first { @@ -407,16 +409,16 @@ fn uu_head(options: &HeadOptions) -> Result<(), u32> { match options.mode { Modes::Bytes(n) => { if options.all_but_last { - rbuf_but_last_n_bytes(&mut stdin, n) + read_but_last_n_bytes(&mut stdin, n) } else { - rbuf_n_bytes(&mut stdin, n) + read_n_bytes(&mut stdin, n) } } Modes::Lines(n) => { if options.all_but_last { - rbuf_but_last_n_lines(&mut stdin, n, options.zeroed) + read_but_last_n_lines(&mut stdin, n, options.zeroed) } else { - rbuf_n_lines(&mut stdin, n, options.zeroed) + read_n_lines(&mut stdin, n, options.zeroed) } } } @@ -451,10 +453,10 @@ fn uu_head(options: &HeadOptions) -> Result<(), u32> { } }; if res.is_err() { - let name = if fname.as_str() == "-" { + let name = if file.as_str() == "-" { "standard input" } else { - fname + file }; let prefix = format!("error reading {}", name); show_error_custom_description!(prefix, "Input/output error"); @@ -502,7 +504,7 @@ mod tests { } #[test] fn test_gnu_compatibility() { - let args = options("-n 1 -c 1 -n 5 -c kiB -vqvqv").unwrap(); + let args = options("-n 1 -c 1 -n 5 -c kiB -vqvqv").unwrap(); // spell-checker:disable-line assert!(args.mode == Modes::Bytes(1024)); assert!(args.verbose); assert_eq!(options("-5").unwrap().mode, Modes::Lines(5)); @@ -584,7 +586,7 @@ mod tests { ); //test that the obsolete syntax is unrolled assert_eq!( - arg_outputs("head -123qvqvqzc"), + arg_outputs("head -123qvqvqzc"), // spell-checker:disable-line Ok("head -q -z -c 123".to_owned()) ); //test that bad obsoletes are an error @@ -604,9 +606,9 @@ mod tests { ); } #[test] - fn rbuf_early_exit() { + fn read_early_exit() { let mut empty = std::io::BufReader::new(std::io::Cursor::new(Vec::new())); - assert!(rbuf_n_bytes(&mut empty, 0).is_ok()); - assert!(rbuf_n_lines(&mut empty, 0, false).is_ok()); + assert!(read_n_bytes(&mut empty, 0).is_ok()); + assert!(read_n_lines(&mut empty, 0, false).is_ok()); } } diff --git a/src/uu/head/src/lines.rs b/src/uu/head/src/lines.rs index dcae27bc8..118aba17f 100644 --- a/src/uu/head/src/lines.rs +++ b/src/uu/head/src/lines.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (vars) zline zlines + //! Iterate over zero-terminated lines. use std::io::BufRead; diff --git a/src/uu/head/src/main.rs b/src/uu/head/src/main.rs index fbeb3381e..3e66a50d0 100644 --- a/src/uu/head/src/main.rs +++ b/src/uu/head/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_head); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_head); diff --git a/src/uu/head/src/parse.rs b/src/uu/head/src/parse.rs index 0cf20be42..f1c97561d 100644 --- a/src/uu/head/src/parse.rs +++ b/src/uu/head/src/parse.rs @@ -7,7 +7,7 @@ pub enum ParseError { Overflow, } /// Parses obsolete syntax -/// head -NUM[kmzv] +/// head -NUM[kmzv] // spell-checker:disable-line pub fn parse_obsolete(src: &str) -> Option, ParseError>> { let mut chars = src.char_indices(); if let Some((_, '-')) = chars.next() { @@ -242,7 +242,7 @@ mod tests { assert_eq!(obsolete("-1mmk"), obsolete_result(&["-c", "1024"])); assert_eq!(obsolete("-1vz"), obsolete_result(&["-v", "-z", "-n", "1"])); assert_eq!( - obsolete("-1vzqvq"), + obsolete("-1vzqvq"), // spell-checker:disable-line obsolete_result(&["-q", "-z", "-n", "1"]) ); assert_eq!(obsolete("-1vzc"), obsolete_result(&["-v", "-z", "-c", "1"])); @@ -257,7 +257,7 @@ mod tests { assert_eq!(obsolete("-5c5"), Some(Err(ParseError::Syntax))); } #[test] - fn test_parse_obsolete_nomatch() { + fn test_parse_obsolete_no_match() { assert_eq!(obsolete("-k"), None); assert_eq!(obsolete("asd"), None); } diff --git a/src/uu/hostid/src/main.rs b/src/uu/hostid/src/main.rs index 12b1178ec..9645ed4a6 100644 --- a/src/uu/hostid/src/main.rs +++ b/src/uu/hostid/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_hostid); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_hostid); diff --git a/src/uu/hostname/src/main.rs b/src/uu/hostname/src/main.rs index a483a8b1a..1d6e6733e 100644 --- a/src/uu/hostname/src/main.rs +++ b/src/uu/hostname/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_hostname); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_hostname); diff --git a/src/uu/id/src/main.rs b/src/uu/id/src/main.rs index 389e2deff..c8f6fe6aa 100644 --- a/src/uu/id/src/main.rs +++ b/src/uu/id/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_id); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_id); diff --git a/src/uu/install/src/main.rs b/src/uu/install/src/main.rs index 289079daf..d296ec4a2 100644 --- a/src/uu/install/src/main.rs +++ b/src/uu/install/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_install); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_install); diff --git a/src/uu/join/src/main.rs b/src/uu/join/src/main.rs index 75be18875..5114252cd 100644 --- a/src/uu/join/src/main.rs +++ b/src/uu/join/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_join); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_join); diff --git a/src/uu/kill/src/main.rs b/src/uu/kill/src/main.rs index c9f639967..91d0a28f0 100644 --- a/src/uu/kill/src/main.rs +++ b/src/uu/kill/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_kill); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_kill); diff --git a/src/uu/link/src/main.rs b/src/uu/link/src/main.rs index d837b4278..ccc565fed 100644 --- a/src/uu/link/src/main.rs +++ b/src/uu/link/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_link); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_link); diff --git a/src/uu/ln/src/ln.rs b/src/uu/ln/src/ln.rs index 04358a415..2a14f3c9c 100644 --- a/src/uu/ln/src/ln.rs +++ b/src/uu/ln/src/ln.rs @@ -371,21 +371,21 @@ fn link_files_in_dir(files: &[PathBuf], target_dir: &Path, settings: &Settings) } fn relative_path<'a>(src: &Path, dst: &Path) -> Result> { - let abssrc = canonicalize(src, CanonicalizeMode::Normal)?; - let absdst = canonicalize(dst, CanonicalizeMode::Normal)?; - let suffix_pos = abssrc + let src_abs = canonicalize(src, CanonicalizeMode::Normal)?; + let dst_abs = canonicalize(dst, CanonicalizeMode::Normal)?; + let suffix_pos = src_abs .components() - .zip(absdst.components()) + .zip(dst_abs.components()) .take_while(|(s, d)| s == d) .count(); - let srciter = abssrc.components().skip(suffix_pos).map(|x| x.as_os_str()); + let src_iter = src_abs.components().skip(suffix_pos).map(|x| x.as_os_str()); - let result: PathBuf = absdst + let result: PathBuf = dst_abs .components() .skip(suffix_pos + 1) .map(|_| OsStr::new("..")) - .chain(srciter) + .chain(src_iter) .collect(); Ok(result.into()) } diff --git a/src/uu/ln/src/main.rs b/src/uu/ln/src/main.rs index de14d10bd..060001972 100644 --- a/src/uu/ln/src/main.rs +++ b/src/uu/ln/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_ln); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_ln); diff --git a/src/uu/logname/src/main.rs b/src/uu/logname/src/main.rs index 48a4063f1..f9cf6160e 100644 --- a/src/uu/logname/src/main.rs +++ b/src/uu/logname/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_logname); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_logname); diff --git a/src/uu/ls/BENCHMARKING.md b/src/uu/ls/BENCHMARKING.md index b009b703a..6bc157805 100644 --- a/src/uu/ls/BENCHMARKING.md +++ b/src/uu/ls/BENCHMARKING.md @@ -1,7 +1,7 @@ # Benchmarking ls ls majorly involves fetching a lot of details (depending upon what details are requested, eg. time/date, inode details, etc) for each path using system calls. Ideally, any system call should be done only once for each of the paths - not adhering to this principle leads to a lot of system call overhead multiplying and bubbling up, especially for recursive ls, therefore it is important to always benchmark multiple scenarios. -This is an overwiew over what was benchmarked, and if you make changes to `ls`, you are encouraged to check +This is an overview over what was benchmarked, and if you make changes to `ls`, you are encouraged to check how performance was affected for the workloads listed below. Feel free to add other workloads to the list that we should improve / make sure not to regress. @@ -55,5 +55,5 @@ However, if the `-R` option is given, the output becomes pretty much useless due #!/bin/bash cargo build --release --no-default-features --features ls perf record target/release/coreutils ls "$@" -perf script | uniq | inferno-collapse-perf | inferno-flamegraph > flamegraph.svg -``` \ No newline at end of file +perf script | uniq | inferno-collapse-perf | inferno-flamegraph > flamegraph.svg +``` diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 5846cb0aa..3e8e908dd 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -60,7 +60,7 @@ fn get_usage() -> String { pub mod options { pub mod format { - pub static ONELINE: &str = "1"; + pub static ONE_LINE: &str = "1"; pub static LONG: &str = "long"; pub static COLUMNS: &str = "C"; pub static ACROSS: &str = "x"; @@ -248,7 +248,7 @@ impl Config { // -og should hide both owner and group. Furthermore, they are not // reset if -l or --format=long is used. So these should just show the // group: -gl or "-g --format=long". Finally, they are also not reset - // when switching to a different format option inbetween like this: + // when switching to a different format option in-between like this: // -ogCl or "-og --format=vertical --format=long". // // -1 has a similar issue: it does nothing if the format is long. This @@ -275,7 +275,7 @@ impl Config { .any(|i| i >= idx) { format = Format::Long; - } else if let Some(mut indices) = options.indices_of(options::format::ONELINE) { + } else if let Some(mut indices) = options.indices_of(options::format::ONE_LINE) { if indices.any(|i| i > idx) { format = Format::OneLine; } @@ -636,8 +636,8 @@ pub fn uumain(args: impl uucore::Args) -> i32 { // ls -1g1 // even though `ls -11` and `ls -1 -g -1` work. .arg( - Arg::with_name(options::format::ONELINE) - .short(options::format::ONELINE) + Arg::with_name(options::format::ONE_LINE) + .short(options::format::ONE_LINE) .help("List one file per line.") .multiple(true) ) @@ -1130,7 +1130,7 @@ impl PathData { let display_name = if let Some(name) = file_name { name } else { - let display_osstr = if command_line { + let display_os_str = if command_line { p_buf.as_os_str() } else { p_buf @@ -1138,7 +1138,7 @@ impl PathData { .unwrap_or_else(|| p_buf.iter().next_back().unwrap()) }; - display_osstr.to_string_lossy().into_owned() + display_os_str.to_string_lossy().into_owned() }; let must_dereference = match &config.dereference { Dereference::All => true, @@ -1624,6 +1624,7 @@ fn display_date(metadata: &Metadata, config: &Config) -> String { TimeStyle::Locale => { let fmt = if recent { "%b %e %H:%M" } else { "%b %e %Y" }; + // spell-checker:ignore (word) datetime //In this version of chrono translating can be done //The function is chrono::datetime::DateTime::format_localized //However it's currently still hard to get the current pure-rust-locale @@ -1678,7 +1679,7 @@ fn display_size_or_rdev(metadata: &Metadata, config: &Config) -> String { } fn display_size(size: u64, config: &Config) -> String { - // NOTE: The human-readable behaviour deviates from the GNU ls. + // NOTE: The human-readable behavior deviates from the GNU ls. // The GNU ls uses binary prefixes by default. match config.size_format { SizeFormat::Binary => format_prefixed(NumberPrefix::binary(size as f64)), @@ -1692,7 +1693,7 @@ fn file_is_executable(md: &Metadata) -> bool { // Mode always returns u32, but the flags might not be, based on the platform // e.g. linux has u32, mac has u16. // S_IXUSR -> user has execute permission - // S_IXGRP -> group has execute persmission + // S_IXGRP -> group has execute permission // S_IXOTH -> other users have execute permission md.mode() & ((S_IXUSR | S_IXGRP | S_IXOTH) as u32) != 0 } diff --git a/src/uu/ls/src/main.rs b/src/uu/ls/src/main.rs index f45314577..d867c3843 100644 --- a/src/uu/ls/src/main.rs +++ b/src/uu/ls/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_ls); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_ls); diff --git a/src/uu/ls/src/quoting_style.rs b/src/uu/ls/src/quoting_style.rs index 01bffa7ec..f9ba55f7b 100644 --- a/src/uu/ls/src/quoting_style.rs +++ b/src/uu/ls/src/quoting_style.rs @@ -304,6 +304,8 @@ pub(super) fn escape_name(name: &str, style: &QuotingStyle) -> String { #[cfg(test)] mod tests { + // spell-checker:ignore (tests/words) one\'two one'two + use crate::quoting_style::{escape_name, Quotes, QuotingStyle}; fn get_style(s: &str) -> QuotingStyle { match s { diff --git a/src/uu/ls/src/version_cmp.rs b/src/uu/ls/src/version_cmp.rs index 4cd39f916..e3f7e29e3 100644 --- a/src/uu/ls/src/version_cmp.rs +++ b/src/uu/ls/src/version_cmp.rs @@ -83,7 +83,7 @@ pub(crate) fn version_cmp(a: &Path, b: &Path) -> Ordering { Ordering::Equal => {} x => return x, }, - // Otherise, we compare the options (because None < Some(_)) + // Otherwise, we compare the options (because None < Some(_)) (a_opt, b_opt) => match a_opt.cmp(&b_opt) { // If they are completely equal except for leading zeroes, we use the leading zeroes. Ordering::Equal => return leading_zeroes, @@ -203,6 +203,7 @@ mod tests { ); assert_eq!( + // spell-checker:disable-next-line version_cmp(&PathBuf::from("file1000"), &PathBuf::from("fileapple")), Ordering::Less, "Numbers in the middle of the name are sorted before other characters" diff --git a/src/uu/mkdir/src/main.rs b/src/uu/mkdir/src/main.rs index 3850113b9..fa6855c93 100644 --- a/src/uu/mkdir/src/main.rs +++ b/src/uu/mkdir/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_mkdir); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_mkdir); diff --git a/src/uu/mkfifo/src/main.rs b/src/uu/mkfifo/src/main.rs index 489dc8ffd..3ad5a3bed 100644 --- a/src/uu/mkfifo/src/main.rs +++ b/src/uu/mkfifo/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_mkfifo); // spell-checker:ignore procs uucore mkfifo +uucore_procs::main!(uu_mkfifo); diff --git a/src/uu/mknod/src/main.rs b/src/uu/mknod/src/main.rs index f3878199b..b65a20cd4 100644 --- a/src/uu/mknod/src/main.rs +++ b/src/uu/mknod/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_mknod); // spell-checker:ignore procs uucore mknod +uucore_procs::main!(uu_mknod); diff --git a/src/uu/mknod/src/mknod.rs b/src/uu/mknod/src/mknod.rs index e0cf62024..57bdd3052 100644 --- a/src/uu/mknod/src/mknod.rs +++ b/src/uu/mknod/src/mknod.rs @@ -50,12 +50,12 @@ fn makedev(maj: u64, min: u64) -> dev_t { } #[cfg(windows)] -fn _makenod(file_name: &str, mode: mode_t, dev: dev_t) -> i32 { +fn _mknod(file_name: &str, mode: mode_t, dev: dev_t) -> i32 { panic!("Unsupported for windows platform") } #[cfg(unix)] -fn _makenod(file_name: &str, mode: mode_t, dev: dev_t) -> i32 { +fn _mknod(file_name: &str, mode: mode_t, dev: dev_t) -> i32 { let c_str = CString::new(file_name).expect("Failed to convert to CString"); // the user supplied a mode @@ -158,7 +158,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { eprintln!("Try '{} --help' for more information.", NAME); 1 } else { - _makenod(file_name, S_IFIFO | mode, 0) + _mknod(file_name, S_IFIFO | mode, 0) } } else { match (matches.value_of("major"), matches.value_of("minor")) { @@ -174,10 +174,10 @@ pub fn uumain(args: impl uucore::Args) -> i32 { let dev = makedev(major, minor); if ch == 'b' { // block special file - _makenod(file_name, S_IFBLK | mode, dev) + _mknod(file_name, S_IFBLK | mode, dev) } else if ch == 'c' || ch == 'u' { // char special file - _makenod(file_name, S_IFCHR | mode, dev) + _mknod(file_name, S_IFCHR | mode, dev) } else { unreachable!("{} was validated to be only b, c or u", ch); } diff --git a/src/uu/mknod/src/parsemode.rs b/src/uu/mknod/src/parsemode.rs index 026fc4a56..2767cb303 100644 --- a/src/uu/mknod/src/parsemode.rs +++ b/src/uu/mknod/src/parsemode.rs @@ -1,4 +1,4 @@ -// spell-checker:ignore (ToDO) fperm +// spell-checker:ignore (path) osrelease use libc::{mode_t, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR}; diff --git a/src/uu/mktemp/src/main.rs b/src/uu/mktemp/src/main.rs index 217f09372..020284655 100644 --- a/src/uu/mktemp/src/main.rs +++ b/src/uu/mktemp/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_mktemp); // spell-checker:ignore procs uucore mktemp +uucore_procs::main!(uu_mktemp); diff --git a/src/uu/mktemp/src/mktemp.rs b/src/uu/mktemp/src/mktemp.rs index f6c244bf2..f7c87495c 100644 --- a/src/uu/mktemp/src/mktemp.rs +++ b/src/uu/mktemp/src/mktemp.rs @@ -6,7 +6,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (ToDO) tempfile tempdir SUFF TMPDIR tmpname +// spell-checker:ignore (paths) GPGHome #[macro_use] extern crate uucore; @@ -67,10 +67,10 @@ pub fn uumain(args: impl uucore::Args) -> i32 { Arg::with_name(OPT_SUFFIX) .long(OPT_SUFFIX) .help( - "append SUFF to TEMPLATE; SUFF must not contain a path separator. \ + "append SUFFIX to TEMPLATE; SUFFIX must not contain a path separator. \ This option is implied if TEMPLATE does not end with X.", ) - .value_name("SUFF"), + .value_name("SUFFIX"), ) .arg( Arg::with_name(OPT_TMPDIR) diff --git a/src/uu/more/src/main.rs b/src/uu/more/src/main.rs index 1f3137265..15fbf51f9 100644 --- a/src/uu/more/src/main.rs +++ b/src/uu/more/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_more); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_more); diff --git a/src/uu/more/src/more.rs b/src/uu/more/src/more.rs index c4a13aa1b..482c5491d 100644 --- a/src/uu/more/src/more.rs +++ b/src/uu/more/src/more.rs @@ -5,7 +5,7 @@ // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. -// spell-checker:ignore (ToDO) lflag ICANON tcgetattr tcsetattr TCSADRAIN +// spell-checker:ignore (methods) isnt #[macro_use] extern crate uucore; @@ -100,7 +100,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .long(options::LINES) .value_name("number") .takes_value(true) - .help("The number of lines per screenful"), + .help("The number of lines per screen full"), ) .arg( Arg::with_name(options::NUMBER) @@ -135,30 +135,27 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .help("Path to the files to be read"), ) .get_matches_from(args); - + let mut buff = String::new(); - if let Some(filenames) = matches.values_of(options::FILES) { + if let Some(files) = matches.values_of(options::FILES) { let mut stdout = setup_term(); - let length = filenames.len(); - for (idx, fname) in filenames.enumerate() { - let fname = Path::new(fname); - if fname.is_dir() { + let length = files.len(); + for (idx, file) in files.enumerate() { + let file = Path::new(file); + if file.is_dir() { terminal::disable_raw_mode().unwrap(); - show_usage_error!("'{}' is a directory.", fname.display()); + show_usage_error!("'{}' is a directory.", file.display()); return 1; } - if !fname.exists() { + if !file.exists() { terminal::disable_raw_mode().unwrap(); - show_error!( - "cannot open {}: No such file or directory", - fname.display() - ); + show_error!("cannot open {}: No such file or directory", file.display()); return 1; } if length > 1 { - buff.push_str(&MULTI_FILE_TOP_PROMPT.replace("{}", fname.to_str().unwrap())); + buff.push_str(&MULTI_FILE_TOP_PROMPT.replace("{}", file.to_str().unwrap())); } - let mut reader = BufReader::new(File::open(fname).unwrap()); + let mut reader = BufReader::new(File::open(file).unwrap()); reader.read_to_string(&mut buff).unwrap(); let is_last = idx + 1 == length; more(&buff, &mut stdout, is_last); @@ -220,7 +217,7 @@ fn more(buff: &str, mut stdout: &mut Stdout, is_last: bool) { ); // Specifies whether we have reached the end of the file and should - // return on the next keypress. However, we immediately return when + // return on the next key press. However, we immediately return when // this is the last file. let mut to_be_done = false; if lines_left == 0 && is_last { @@ -230,7 +227,7 @@ fn more(buff: &str, mut stdout: &mut Stdout, is_last: bool) { to_be_done = true; } } - + loop { if event::poll(Duration::from_millis(10)).unwrap() { match event::read().unwrap() { @@ -254,7 +251,6 @@ fn more(buff: &str, mut stdout: &mut Stdout, is_last: bool) { modifiers: KeyModifiers::NONE, }) => { upper_mark = upper_mark.saturating_add(rows.saturating_sub(1)); - } Event::Key(KeyEvent { code: KeyCode::Up, @@ -275,7 +271,7 @@ fn more(buff: &str, mut stdout: &mut Stdout, is_last: bool) { if lines_left == 0 { if to_be_done || is_last { - return + return; } to_be_done = true; } diff --git a/src/uu/mv/src/main.rs b/src/uu/mv/src/main.rs index c7e321234..49f7956e8 100644 --- a/src/uu/mv/src/main.rs +++ b/src/uu/mv/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_mv); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_mv); diff --git a/src/uu/nice/src/main.rs b/src/uu/nice/src/main.rs index 25da035aa..039f40d9d 100644 --- a/src/uu/nice/src/main.rs +++ b/src/uu/nice/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_nice); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_nice); diff --git a/src/uu/nl/src/helper.rs b/src/uu/nl/src/helper.rs index e31477c62..562cdeb93 100644 --- a/src/uu/nl/src/helper.rs +++ b/src/uu/nl/src/helper.rs @@ -29,7 +29,7 @@ pub fn parse_options(settings: &mut crate::Settings, opts: &clap::ArgMatches) -> // This vector holds error messages encountered. let mut errs: Vec = vec![]; settings.renumber = !opts.is_present(options::NO_RENUMBER); - match opts.value_of(options::NUMER_SEPARATOR) { + match opts.value_of(options::NUMBER_SEPARATOR) { None => {} Some(val) => { settings.number_separator = val.to_owned(); @@ -118,7 +118,7 @@ pub fn parse_options(settings: &mut crate::Settings, opts: &clap::ArgMatches) -> } } } - match opts.value_of(options::STARTING_LINE_NUMER) { + match opts.value_of(options::STARTING_LINE_NUMBER) { None => {} Some(val) => { let conv: Option = val.parse().ok(); diff --git a/src/uu/nl/src/main.rs b/src/uu/nl/src/main.rs index fac355069..072fad504 100644 --- a/src/uu/nl/src/main.rs +++ b/src/uu/nl/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_nl); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_nl); diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index 7c5f01811..69adbed41 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -79,8 +79,8 @@ pub mod options { pub const JOIN_BLANK_LINES: &str = "join-blank-lines"; pub const NUMBER_FORMAT: &str = "number-format"; pub const NO_RENUMBER: &str = "no-renumber"; - pub const NUMER_SEPARATOR: &str = "number-separator"; - pub const STARTING_LINE_NUMER: &str = "starting-line-number"; + pub const NUMBER_SEPARATOR: &str = "number-separator"; + pub const STARTING_LINE_NUMBER: &str = "starting-line-number"; pub const NUMBER_WIDTH: &str = "number-width"; } @@ -150,16 +150,16 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .help("do not reset line numbers at logical pages"), ) .arg( - Arg::with_name(options::NUMER_SEPARATOR) + Arg::with_name(options::NUMBER_SEPARATOR) .short("s") - .long(options::NUMER_SEPARATOR) + .long(options::NUMBER_SEPARATOR) .help("add STRING after (possible) line number") .value_name("STRING"), ) .arg( - Arg::with_name(options::STARTING_LINE_NUMER) + Arg::with_name(options::STARTING_LINE_NUMBER) .short("v") - .long(options::STARTING_LINE_NUMER) + .long(options::STARTING_LINE_NUMBER) .help("first line number on each logical page") .value_name("NUMBER"), ) diff --git a/src/uu/nohup/src/main.rs b/src/uu/nohup/src/main.rs index d46ceb7cb..2007711f6 100644 --- a/src/uu/nohup/src/main.rs +++ b/src/uu/nohup/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_nohup); // spell-checker:ignore procs uucore nohup +uucore_procs::main!(uu_nohup); diff --git a/src/uu/nproc/src/main.rs b/src/uu/nproc/src/main.rs index 7650cce09..356c2101f 100644 --- a/src/uu/nproc/src/main.rs +++ b/src/uu/nproc/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_nproc); // spell-checker:ignore procs uucore nproc +uucore_procs::main!(uu_nproc); diff --git a/src/uu/numfmt/src/main.rs b/src/uu/numfmt/src/main.rs index 084d494f2..f4d991727 100644 --- a/src/uu/numfmt/src/main.rs +++ b/src/uu/numfmt/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_numfmt); // spell-checker:ignore procs uucore numfmt +uucore_procs::main!(uu_numfmt); diff --git a/src/uu/od/src/main.rs b/src/uu/od/src/main.rs index d5e96180c..3f30d15e8 100644 --- a/src/uu/od/src/main.rs +++ b/src/uu/od/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_od); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_od); diff --git a/src/uu/od/src/od.rs b/src/uu/od/src/od.rs index 571ca543d..7359047b2 100644 --- a/src/uu/od/src/od.rs +++ b/src/uu/od/src/od.rs @@ -5,6 +5,7 @@ // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. +// spell-checker:ignore (clap) DontDelimitTrailingValues // spell-checker:ignore (ToDO) formatteriteminfo inputdecoder inputoffset mockstream nrofbytes partialreader odfunc multifile exitcode #[macro_use] @@ -455,7 +456,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ]); let clap_matches = clap_opts - .clone() // Clone to reuse clap_otps to print help + .clone() // Clone to reuse clap_opts to print help .get_matches_from(args.clone()); if clap_matches.is_present(options::VERSION) { diff --git a/src/uu/od/src/prn_char.rs b/src/uu/od/src/prn_char.rs index cbbb370ce..742229dd7 100644 --- a/src/uu/od/src/prn_char.rs +++ b/src/uu/od/src/prn_char.rs @@ -1,5 +1,3 @@ -// spell-checker:ignore (ToDO) CHRS itembytes MUTF - use std::str::from_utf8; use crate::formatteriteminfo::*; @@ -16,7 +14,7 @@ pub static FORMAT_ITEM_C: FormatterItemInfo = FormatterItemInfo { formatter: FormatWriter::MultibyteWriter(format_item_c), }; -static A_CHRS: [&str; 128] = [ +static A_CHARS: [&str; 128] = [ "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel", "bs", "ht", "nl", "vt", "ff", "cr", "so", "si", "dle", "dc1", "dc2", "dc3", "dc4", "nak", "syn", "etb", "can", "em", "sub", "esc", "fs", "gs", "rs", "us", "sp", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", @@ -28,12 +26,12 @@ static A_CHRS: [&str; 128] = [ ]; fn format_item_a(p: u64) -> String { - // itembytes == 1 + // item-bytes == 1 let b = (p & 0x7f) as u8; - format!("{:>4}", A_CHRS.get(b as usize).unwrap_or(&"??")) + format!("{:>4}", A_CHARS.get(b as usize).unwrap_or(&"??")) } -static C_CHRS: [&str; 128] = [ +static C_CHARS: [&str; 128] = [ "\\0", "001", "002", "003", "004", "005", "006", "\\a", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "016", "017", "020", "021", "022", "023", "024", "025", "026", "027", "030", "031", "032", "033", "034", "035", "036", "037", " ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", @@ -45,11 +43,11 @@ static C_CHRS: [&str; 128] = [ ]; fn format_item_c(bytes: &[u8]) -> String { - // itembytes == 1 + // item-bytes == 1 let b = bytes[0]; if b & 0x80 == 0x00 { - match C_CHRS.get(b as usize) { + match C_CHARS.get(b as usize) { Some(s) => format!("{:>4}", s), None => format!("{:>4}", b), } @@ -86,7 +84,7 @@ pub fn format_ascii_dump(bytes: &[u8]) -> String { result.push('>'); for c in bytes.iter() { if *c >= 0x20 && *c <= 0x7e { - result.push_str(C_CHRS[*c as usize]); + result.push_str(C_CHARS[*c as usize]); } else { result.push('.'); } @@ -136,12 +134,12 @@ fn test_format_item_c() { format_item_c(&[0xf0, 0x9f, 0x92, 0x96, 0x21]) ); - assert_eq!(" 300", format_item_c(&[0xc0, 0x80])); // invalid utf-8 (MUTF-8 null) + assert_eq!(" 300", format_item_c(&[0xc0, 0x80])); // invalid utf-8 (UTF-8 null) assert_eq!(" 301", format_item_c(&[0xc1, 0xa1])); // invalid utf-8 assert_eq!(" 303", format_item_c(&[0xc3, 0xc3])); // invalid utf-8 assert_eq!(" 360", format_item_c(&[0xf0, 0x82, 0x82, 0xac])); // invalid utf-8 (overlong) assert_eq!(" 360", format_item_c(&[0xf0, 0x9f, 0x92])); // invalid utf-8 (missing octet) - assert_eq!(" \u{10FFFD}", format_item_c(&[0xf4, 0x8f, 0xbf, 0xbd])); // largest valid utf-8 + assert_eq!(" \u{10FFFD}", format_item_c(&[0xf4, 0x8f, 0xbf, 0xbd])); // largest valid utf-8 // spell-checker:ignore 10FFFD FFFD assert_eq!(" 364", format_item_c(&[0xf4, 0x90, 0x00, 0x00])); // invalid utf-8 assert_eq!(" 365", format_item_c(&[0xf5, 0x80, 0x80, 0x80])); // invalid utf-8 assert_eq!(" 377", format_item_c(&[0xff])); // invalid utf-8 diff --git a/src/uu/od/src/prn_int.rs b/src/uu/od/src/prn_int.rs index b8397b01b..0946824c1 100644 --- a/src/uu/od/src/prn_int.rs +++ b/src/uu/od/src/prn_int.rs @@ -1,5 +1,3 @@ -// spell-checker:ignore (ToDO) itembytes - use crate::formatteriteminfo::*; /// format string to print octal using `int_writer_unsigned` @@ -60,9 +58,9 @@ macro_rules! int_writer_signed { }; } -/// Extends a signed number in `item` of `itembytes` bytes into a (signed) i64 -fn sign_extend(item: u64, itembytes: usize) -> i64 { - let shift = 64 - itembytes * 8; +/// Extends a signed number in `item` of `item_bytes` bytes into a (signed) i64 +fn sign_extend(item: u64, item_bytes: usize) -> i64 { + let shift = 64 - item_bytes * 8; (item << shift) as i64 >> shift } @@ -89,46 +87,46 @@ int_writer_signed!(FORMAT_ITEM_DEC64S, 8, 21, format_item_dec_s64, DEC!()); // m #[test] fn test_sign_extend() { assert_eq!( - 0xffffffffffffff80u64 as i64, - sign_extend(0x0000000000000080, 1) + 0xffff_ffff_ffff_ff80u64 as i64, + sign_extend(0x0000_0000_0000_0080, 1) ); assert_eq!( - 0xffffffffffff8000u64 as i64, - sign_extend(0x0000000000008000, 2) + 0xffff_ffff_ffff_8000u64 as i64, + sign_extend(0x0000_0000_0000_8000, 2) ); assert_eq!( - 0xffffffffff800000u64 as i64, - sign_extend(0x0000000000800000, 3) + 0xffff_ffff_ff80_0000u64 as i64, + sign_extend(0x0000_0000_0080_0000, 3) ); assert_eq!( - 0xffffffff80000000u64 as i64, - sign_extend(0x0000000080000000, 4) + 0xffff_ffff_8000_0000u64 as i64, + sign_extend(0x0000_0000_8000_0000, 4) ); assert_eq!( - 0xffffff8000000000u64 as i64, - sign_extend(0x0000008000000000, 5) + 0xffff_ff80_0000_0000u64 as i64, + sign_extend(0x0000_0080_0000_0000, 5) ); assert_eq!( - 0xffff800000000000u64 as i64, - sign_extend(0x0000800000000000, 6) + 0xffff_8000_0000_0000u64 as i64, + sign_extend(0x0000_8000_0000_0000, 6) ); assert_eq!( - 0xff80000000000000u64 as i64, - sign_extend(0x0080000000000000, 7) + 0xff80_0000_0000_0000u64 as i64, + sign_extend(0x0080_0000_0000_0000, 7) ); assert_eq!( - 0x8000000000000000u64 as i64, - sign_extend(0x8000000000000000, 8) + 0x8000_0000_0000_0000u64 as i64, + sign_extend(0x8000_0000_0000_0000, 8) ); - assert_eq!(0x000000000000007f, sign_extend(0x000000000000007f, 1)); - assert_eq!(0x0000000000007fff, sign_extend(0x0000000000007fff, 2)); - assert_eq!(0x00000000007fffff, sign_extend(0x00000000007fffff, 3)); - assert_eq!(0x000000007fffffff, sign_extend(0x000000007fffffff, 4)); - assert_eq!(0x0000007fffffffff, sign_extend(0x0000007fffffffff, 5)); - assert_eq!(0x00007fffffffffff, sign_extend(0x00007fffffffffff, 6)); - assert_eq!(0x007fffffffffffff, sign_extend(0x007fffffffffffff, 7)); - assert_eq!(0x7fffffffffffffff, sign_extend(0x7fffffffffffffff, 8)); + assert_eq!(0x0000_0000_0000_007f, sign_extend(0x0000_0000_0000_007f, 1)); + assert_eq!(0x0000_0000_0000_7fff, sign_extend(0x0000_0000_0000_7fff, 2)); + assert_eq!(0x0000_0000_007f_ffff, sign_extend(0x0000_0000_007f_ffff, 3)); + assert_eq!(0x0000_0000_7fff_ffff, sign_extend(0x0000_0000_7fff_ffff, 4)); + assert_eq!(0x0000_007f_ffff_ffff, sign_extend(0x0000_007f_ffff_ffff, 5)); + assert_eq!(0x0000_7fff_ffff_ffff, sign_extend(0x0000_7fff_ffff_ffff, 6)); + assert_eq!(0x007f_ffff_ffff_ffff, sign_extend(0x007f_ffff_ffff_ffff, 7)); + assert_eq!(0x7fff_ffff_ffff_ffff, sign_extend(0x7fff_ffff_ffff_ffff, 8)); } #[test] @@ -138,11 +136,11 @@ fn test_format_item_oct() { assert_eq!(" 000000", format_item_oct16(0)); assert_eq!(" 177777", format_item_oct16(0xffff)); assert_eq!(" 00000000000", format_item_oct32(0)); - assert_eq!(" 37777777777", format_item_oct32(0xffffffff)); + assert_eq!(" 37777777777", format_item_oct32(0xffff_ffff)); assert_eq!(" 0000000000000000000000", format_item_oct64(0)); assert_eq!( " 1777777777777777777777", - format_item_oct64(0xffffffffffffffff) + format_item_oct64(0xffff_ffff_ffff_ffff) ); } @@ -153,9 +151,12 @@ fn test_format_item_hex() { assert_eq!(" 0000", format_item_hex16(0)); assert_eq!(" ffff", format_item_hex16(0xffff)); assert_eq!(" 00000000", format_item_hex32(0)); - assert_eq!(" ffffffff", format_item_hex32(0xffffffff)); + assert_eq!(" ffffffff", format_item_hex32(0xffff_ffff)); assert_eq!(" 0000000000000000", format_item_hex64(0)); - assert_eq!(" ffffffffffffffff", format_item_hex64(0xffffffffffffffff)); + assert_eq!( + " ffffffffffffffff", + format_item_hex64(0xffff_ffff_ffff_ffff) + ); } #[test] @@ -165,11 +166,11 @@ fn test_format_item_dec_u() { assert_eq!(" 0", format_item_dec_u16(0)); assert_eq!(" 65535", format_item_dec_u16(0xffff)); assert_eq!(" 0", format_item_dec_u32(0)); - assert_eq!(" 4294967295", format_item_dec_u32(0xffffffff)); + assert_eq!(" 4294967295", format_item_dec_u32(0xffff_ffff)); assert_eq!(" 0", format_item_dec_u64(0)); assert_eq!( " 18446744073709551615", - format_item_dec_u64(0xffffffffffffffff) + format_item_dec_u64(0xffff_ffff_ffff_ffff) ); } @@ -182,15 +183,15 @@ fn test_format_item_dec_s() { assert_eq!(" 32767", format_item_dec_s16(0x7fff)); assert_eq!(" -32768", format_item_dec_s16(0x8000)); assert_eq!(" 0", format_item_dec_s32(0)); - assert_eq!(" 2147483647", format_item_dec_s32(0x7fffffff)); - assert_eq!(" -2147483648", format_item_dec_s32(0x80000000)); + assert_eq!(" 2147483647", format_item_dec_s32(0x7fff_ffff)); + assert_eq!(" -2147483648", format_item_dec_s32(0x8000_0000)); assert_eq!(" 0", format_item_dec_s64(0)); assert_eq!( " 9223372036854775807", - format_item_dec_s64(0x7fffffffffffffff) + format_item_dec_s64(0x7fff_ffff_ffff_ffff) ); assert_eq!( " -9223372036854775808", - format_item_dec_s64(0x8000000000000000) + format_item_dec_s64(0x8000_0000_0000_0000) ); } diff --git a/src/uu/paste/src/main.rs b/src/uu/paste/src/main.rs index bb9b25a68..1d4458b9e 100644 --- a/src/uu/paste/src/main.rs +++ b/src/uu/paste/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_paste); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_paste); diff --git a/src/uu/pathchk/src/main.rs b/src/uu/pathchk/src/main.rs index e16353196..2b7c3b3ee 100644 --- a/src/uu/pathchk/src/main.rs +++ b/src/uu/pathchk/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_pathchk); // spell-checker:ignore procs uucore pathchk +uucore_procs::main!(uu_pathchk); diff --git a/src/uu/pinky/src/main.rs b/src/uu/pinky/src/main.rs index 1bf1e618a..5414c42cc 100644 --- a/src/uu/pinky/src/main.rs +++ b/src/uu/pinky/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_pinky); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_pinky); diff --git a/src/uu/printenv/src/main.rs b/src/uu/printenv/src/main.rs index 328c3b485..b61cbe90a 100644 --- a/src/uu/printenv/src/main.rs +++ b/src/uu/printenv/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_printenv); // spell-checker:ignore procs uucore printenv +uucore_procs::main!(uu_printenv); diff --git a/src/uu/printf/src/main.rs b/src/uu/printf/src/main.rs index aa9a45be5..9def7dafe 100644 --- a/src/uu/printf/src/main.rs +++ b/src/uu/printf/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_printf); // spell-checker:ignore procs uucore printf +uucore_procs::main!(uu_printf); diff --git a/src/uu/printf/src/tokenize/num_format/format_field.rs b/src/uu/printf/src/tokenize/num_format/format_field.rs index 68786e815..02998cde5 100644 --- a/src/uu/printf/src/tokenize/num_format/format_field.rs +++ b/src/uu/printf/src/tokenize/num_format/format_field.rs @@ -1,4 +1,4 @@ -// spell-checker:ignore (ToDO) conv intf strf floatf scif charf fieldtype vals subparser unescaping submodule Cninety inprefix hexifying glibc floatnum rten rhex arrnum fprim interp +// spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety //! Primitives used by Sub Tokenizer //! and num_format modules diff --git a/src/uu/printf/src/tokenize/num_format/formatter.rs b/src/uu/printf/src/tokenize/num_format/formatter.rs index 35faff2a9..f5f5d71b1 100644 --- a/src/uu/printf/src/tokenize/num_format/formatter.rs +++ b/src/uu/printf/src/tokenize/num_format/formatter.rs @@ -1,5 +1,3 @@ -// spell-checker:ignore (ToDO) inprefix for conv - //! Primitives used by num_format and sub_modules. //! never dealt with above (e.g. Sub Tokenizer never uses these) @@ -41,7 +39,7 @@ pub enum Base { // information from the beginning of a numeric argument // the precedes the beginning of a numeric value -pub struct InPrefix { +pub struct InitialPrefix { pub radix_in: Base, pub sign: i8, pub offset: usize, @@ -54,7 +52,7 @@ pub trait Formatter { fn get_primitive( &self, field: &FormatField, - inprefix: &InPrefix, + in_prefix: &InitialPrefix, str_in: &str, ) -> Option; // return a string from a FormatPrimitive, diff --git a/src/uu/printf/src/tokenize/num_format/formatters/base_conv/mod.rs b/src/uu/printf/src/tokenize/num_format/formatters/base_conv/mod.rs index 7d1d805c6..a20f03a95 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/base_conv/mod.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/base_conv/mod.rs @@ -1,4 +1,4 @@ -// spell-checker:ignore (ToDO) arrnum mult basenum bufferval refd vals arrfloat conv intermed addl +// spell-checker:ignore (ToDO) arrnum arr_num mult basenum bufferval refd vals arrfloat conv intermed addl pub fn arrnum_int_mult(arr_num: &[u8], basenum: u8, base_ten_int_fact: u8) -> Vec { let mut carry: u16 = 0; diff --git a/src/uu/printf/src/tokenize/num_format/formatters/base_conv/tests.rs b/src/uu/printf/src/tokenize/num_format/formatters/base_conv/tests.rs index fcac4392e..7945d41ac 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/base_conv/tests.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/base_conv/tests.rs @@ -1,4 +1,4 @@ -// spell-checker:ignore (ToDO) conv arrnum mult shortcircuit +// spell-checker:ignore (ToDO) arrnum mult #[cfg(test)] use super::*; @@ -29,7 +29,7 @@ fn test_arrnum_int_non_base_10() { } #[test] -fn test_arrnum_int_div_shortcircuit() { +fn test_arrnum_int_div_short_circuit() { // ( let arrnum: Vec = vec![5, 5, 5, 5, 0]; let base_num = 10; diff --git a/src/uu/printf/src/tokenize/num_format/formatters/cninetyninehexfloatf.rs b/src/uu/printf/src/tokenize/num_format/formatters/cninetyninehexfloatf.rs index 870e64712..f96a991b5 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/cninetyninehexfloatf.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/cninetyninehexfloatf.rs @@ -1,8 +1,9 @@ -// spell-checker:ignore (ToDO) conv intf strf floatf scif charf fieldtype vals subparser unescaping submodule Cninety inprefix hexifying glibc floatnum rten rhex arrnum +// spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety +// spell-checker:ignore (ToDO) arrnum //! formatter for %a %F C99 Hex-floating-point subs use super::super::format_field::FormatField; -use super::super::formatter::{FormatPrimitive, Formatter, InPrefix}; +use super::super::formatter::{FormatPrimitive, Formatter, InitialPrefix}; use super::base_conv; use super::base_conv::RadixDef; use super::float_common::{primitive_to_str_common, FloatAnalysis}; @@ -20,15 +21,20 @@ impl Formatter for CninetyNineHexFloatf { fn get_primitive( &self, field: &FormatField, - inprefix: &InPrefix, + initial_prefix: &InitialPrefix, str_in: &str, ) -> Option { let second_field = field.second_field.unwrap_or(6) + 1; - let analysis = - FloatAnalysis::analyze(&str_in, inprefix, Some(second_field as usize), None, true); + let analysis = FloatAnalysis::analyze( + &str_in, + initial_prefix, + Some(second_field as usize), + None, + true, + ); let f = get_primitive_hex( - inprefix, - &str_in[inprefix.offset..], + initial_prefix, + &str_in[initial_prefix.offset..], &analysis, second_field as usize, *field.field_char == 'A', @@ -44,13 +50,17 @@ impl Formatter for CninetyNineHexFloatf { // on the todo list is to have a trait for get_primitive that is implemented by each float formatter and can override a default. when that happens we can take the parts of get_primitive_dec specific to dec and spin them out to their own functions that can be overridden. fn get_primitive_hex( - inprefix: &InPrefix, + initial_prefix: &InitialPrefix, _str_in: &str, _analysis: &FloatAnalysis, _last_dec_place: usize, capitalized: bool, ) -> FormatPrimitive { - let prefix = Some(String::from(if inprefix.sign == -1 { "-0x" } else { "0x" })); + let prefix = Some(String::from(if initial_prefix.sign == -1 { + "-0x" + } else { + "0x" + })); // TODO actual conversion, make sure to get back mantissa. // for hex to hex, it's really just a matter of moving the @@ -63,7 +73,7 @@ fn get_primitive_hex( // the difficult part of this (arrnum_int_div_step) is already implemented. // the hex float name may be a bit misleading in terms of how to go about the - // conversion. The best way to do it is to just convert the floatnum + // conversion. The best way to do it is to just convert the float number // directly to base 2 and then at the end translate back to hex. let mantissa = 0; let suffix = Some({ @@ -82,15 +92,15 @@ fn get_primitive_hex( } fn to_hex(src: &str, before_decimal: bool) -> String { - let rten = base_conv::RadixTen; - let rhex = base_conv::RadixHex; + let radix_ten = base_conv::RadixTen; + let radix_hex = base_conv::RadixHex; if before_decimal { - base_conv::base_conv_str(src, &rten, &rhex) + base_conv::base_conv_str(src, &radix_ten, &radix_hex) } else { - let as_arrnum_ten = base_conv::str_to_arrnum(src, &rten); + let as_arrnum_ten = base_conv::str_to_arrnum(src, &radix_ten); let s = format!( "{}", - base_conv::base_conv_float(&as_arrnum_ten, rten.get_max(), rhex.get_max()) + base_conv::base_conv_float(&as_arrnum_ten, radix_ten.get_max(), radix_hex.get_max()) ); if s.len() > 2 { String::from(&s[2..]) diff --git a/src/uu/printf/src/tokenize/num_format/formatters/decf.rs b/src/uu/printf/src/tokenize/num_format/formatters/decf.rs index 448771f22..5798eadcb 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/decf.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/decf.rs @@ -1,22 +1,22 @@ -// spell-checker:ignore (ToDO) conv intf strf floatf scif charf fieldtype vals subparser unescaping submodule Cninety inprefix hexifying glibc floatnum rten rhex arrnum fprim interp +// spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety //! formatter for %g %G decimal subs use super::super::format_field::FormatField; -use super::super::formatter::{FormatPrimitive, Formatter, InPrefix}; +use super::super::formatter::{FormatPrimitive, Formatter, InitialPrefix}; use super::float_common::{get_primitive_dec, primitive_to_str_common, FloatAnalysis}; -fn get_len_fprim(fprim: &FormatPrimitive) -> usize { +fn get_len_fmt_primitive(fmt: &FormatPrimitive) -> usize { let mut len = 0; - if let Some(ref s) = fprim.prefix { + if let Some(ref s) = fmt.prefix { len += s.len(); } - if let Some(ref s) = fprim.pre_decimal { + if let Some(ref s) = fmt.pre_decimal { len += s.len(); } - if let Some(ref s) = fprim.post_decimal { + if let Some(ref s) = fmt.post_decimal { len += s.len(); } - if let Some(ref s) = fprim.suffix { + if let Some(ref s) = fmt.suffix { len += s.len(); } len @@ -33,22 +33,22 @@ impl Formatter for Decf { fn get_primitive( &self, field: &FormatField, - inprefix: &InPrefix, + initial_prefix: &InitialPrefix, str_in: &str, ) -> Option { let second_field = field.second_field.unwrap_or(6) + 1; - // default to scif interp. so as to not truncate input vals + // default to scif interpretation so as to not truncate input vals // (that would be displayed in scif) based on relation to decimal place let analysis = FloatAnalysis::analyze( str_in, - inprefix, + initial_prefix, Some(second_field as usize + 1), None, false, ); let mut f_sci = get_primitive_dec( - inprefix, - &str_in[inprefix.offset..], + initial_prefix, + &str_in[initial_prefix.offset..], &analysis, second_field as usize, Some(*field.field_char == 'G'), @@ -70,17 +70,19 @@ impl Formatter for Decf { } } let f_fl = get_primitive_dec( - inprefix, - &str_in[inprefix.offset..], + initial_prefix, + &str_in[initial_prefix.offset..], &analysis, second_field as usize, None, ); - Some(if get_len_fprim(&f_fl) >= get_len_fprim(&f_sci) { - f_sci - } else { - f_fl - }) + Some( + if get_len_fmt_primitive(&f_fl) >= get_len_fmt_primitive(&f_sci) { + f_sci + } else { + f_fl + }, + ) } fn primitive_to_str(&self, prim: &FormatPrimitive, field: FormatField) -> String { primitive_to_str_common(prim, &field) diff --git a/src/uu/printf/src/tokenize/num_format/formatters/float_common.rs b/src/uu/printf/src/tokenize/num_format/formatters/float_common.rs index a107078ae..dd8259233 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/float_common.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/float_common.rs @@ -1,7 +1,10 @@ -// spell-checker:ignore (ToDO) conv intf strf floatf scif charf fieldtype vals subparser unescaping submodule Cninety inprefix hexifying glibc floatnum rten rhex arrnum +// spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety +// spell-checker:ignore (ToDO) arrnum use super::super::format_field::FormatField; -use super::super::formatter::{get_it_at, warn_incomplete_conv, Base, FormatPrimitive, InPrefix}; +use super::super::formatter::{ + get_it_at, warn_incomplete_conv, Base, FormatPrimitive, InitialPrefix, +}; use super::base_conv; use super::base_conv::RadixDef; @@ -39,7 +42,7 @@ fn has_enough_digits( impl FloatAnalysis { pub fn analyze( str_in: &str, - inprefix: &InPrefix, + initial_prefix: &InitialPrefix, max_sd_opt: Option, max_after_dec_opt: Option, hex_output: bool, @@ -47,13 +50,13 @@ impl FloatAnalysis { // this fn assumes // the input string // has no leading spaces or 0s - let str_it = get_it_at(inprefix.offset, str_in); + let str_it = get_it_at(initial_prefix.offset, str_in); let mut ret = FloatAnalysis { len_important: 0, decimal_pos: None, follow: None, }; - let hex_input = match inprefix.radix_in { + let hex_input = match initial_prefix.radix_in { Base::Hex => true, Base::Ten => false, Base::Octal => { @@ -126,15 +129,15 @@ impl FloatAnalysis { } fn de_hex(src: &str, before_decimal: bool) -> String { - let rten = base_conv::RadixTen; - let rhex = base_conv::RadixHex; + let radix_ten = base_conv::RadixTen; + let radix_hex = base_conv::RadixHex; if before_decimal { - base_conv::base_conv_str(src, &rhex, &rten) + base_conv::base_conv_str(src, &radix_hex, &radix_ten) } else { - let as_arrnum_hex = base_conv::str_to_arrnum(src, &rhex); + let as_arrnum_hex = base_conv::str_to_arrnum(src, &radix_hex); let s = format!( "{}", - base_conv::base_conv_float(&as_arrnum_hex, rhex.get_max(), rten.get_max()) + base_conv::base_conv_float(&as_arrnum_hex, radix_hex.get_max(), radix_ten.get_max()) ); if s.len() > 2 { String::from(&s[2..]) @@ -200,7 +203,7 @@ fn round_terminal_digit( } pub fn get_primitive_dec( - inprefix: &InPrefix, + initial_prefix: &InitialPrefix, str_in: &str, analysis: &FloatAnalysis, last_dec_place: usize, @@ -209,7 +212,7 @@ pub fn get_primitive_dec( let mut f: FormatPrimitive = Default::default(); // add negative sign section - if inprefix.sign == -1 { + if initial_prefix.sign == -1 { f.prefix = Some(String::from("-")); } @@ -223,8 +226,8 @@ pub fn get_primitive_dec( if first_segment_raw.is_empty() { first_segment_raw = "0"; } - // convert to string, de_hexifying if input is in hex. - let (first_segment, second_segment) = match inprefix.radix_in { + // convert to string, de_hexifying if input is in hex // spell-checker:disable-line + let (first_segment, second_segment) = match initial_prefix.radix_in { Base::Hex => ( de_hex(first_segment_raw, true), de_hex(second_segment_raw, false), diff --git a/src/uu/printf/src/tokenize/num_format/formatters/floatf.rs b/src/uu/printf/src/tokenize/num_format/formatters/floatf.rs index b3de2f98a..aed50f18e 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/floatf.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/floatf.rs @@ -1,8 +1,9 @@ -// spell-checker:ignore (ToDO) floatf inprefix +// spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety +// spell-checker:ignore (ToDO) arrnum //! formatter for %f %F common-notation floating-point subs use super::super::format_field::FormatField; -use super::super::formatter::{FormatPrimitive, Formatter, InPrefix}; +use super::super::formatter::{FormatPrimitive, Formatter, InitialPrefix}; use super::float_common::{get_primitive_dec, primitive_to_str_common, FloatAnalysis}; pub struct Floatf; @@ -15,15 +16,20 @@ impl Formatter for Floatf { fn get_primitive( &self, field: &FormatField, - inprefix: &InPrefix, + initial_prefix: &InitialPrefix, str_in: &str, ) -> Option { let second_field = field.second_field.unwrap_or(6) + 1; - let analysis = - FloatAnalysis::analyze(&str_in, inprefix, None, Some(second_field as usize), false); + let analysis = FloatAnalysis::analyze( + &str_in, + initial_prefix, + None, + Some(second_field as usize), + false, + ); let f = get_primitive_dec( - inprefix, - &str_in[inprefix.offset..], + initial_prefix, + &str_in[initial_prefix.offset..], &analysis, second_field as usize, None, diff --git a/src/uu/printf/src/tokenize/num_format/formatters/intf.rs b/src/uu/printf/src/tokenize/num_format/formatters/intf.rs index 2e4e67047..02c59211b 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/intf.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/intf.rs @@ -1,11 +1,12 @@ -// spell-checker:ignore (ToDO) fchar conv decr inprefix intf ints finalstr +// spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety +// spell-checker:ignore (ToDO) arrnum //! formatter for unsigned and signed int subs -//! unsigned ints: %X %x (hex u64) %o (octal u64) %u (base ten u64) -//! signed ints: %i %d (both base ten i64) +//! unsigned int: %X %x (hex u64) %o (octal u64) %u (base ten u64) +//! signed int: %i %d (both base ten i64) use super::super::format_field::FormatField; use super::super::formatter::{ - get_it_at, warn_incomplete_conv, Base, FormatPrimitive, Formatter, InPrefix, + get_it_at, warn_incomplete_conv, Base, FormatPrimitive, Formatter, InitialPrefix, }; use std::i64; use std::u64; @@ -38,19 +39,19 @@ impl Intf { // is_zero: true if number is zero, false otherwise // len_digits: length of digits used to create the int // important, for example, if we run into a non-valid character - fn analyze(str_in: &str, signed_out: bool, inprefix: &InPrefix) -> IntAnalysis { + fn analyze(str_in: &str, signed_out: bool, initial_prefix: &InitialPrefix) -> IntAnalysis { // the maximum number of digits we could conceivably // have before the decimal point without exceeding the // max - let mut str_it = get_it_at(inprefix.offset, str_in); + let mut str_it = get_it_at(initial_prefix.offset, str_in); let max_sd_in = if signed_out { - match inprefix.radix_in { + match initial_prefix.radix_in { Base::Ten => 19, Base::Octal => 21, Base::Hex => 16, } } else { - match inprefix.radix_in { + match initial_prefix.radix_in { Base::Ten => 20, Base::Octal => 22, Base::Hex => 16, @@ -118,13 +119,13 @@ impl Intf { } // get a FormatPrimitive of the maximum value for the field char // and given sign - fn get_max(fchar: char, sign: i8) -> FormatPrimitive { - let mut fmt_prim: FormatPrimitive = Default::default(); - fmt_prim.pre_decimal = Some(String::from(match fchar { + fn get_max(field_char: char, sign: i8) -> FormatPrimitive { + let mut fmt_primitive: FormatPrimitive = Default::default(); + fmt_primitive.pre_decimal = Some(String::from(match field_char { 'd' | 'i' => match sign { 1 => "9223372036854775807", _ => { - fmt_prim.prefix = Some(String::from("-")); + fmt_primitive.prefix = Some(String::from("-")); "9223372036854775808" } }, @@ -132,7 +133,7 @@ impl Intf { 'o' => "1777777777777777777777", /* 'u' | */ _ => "18446744073709551615", })); - fmt_prim + fmt_primitive } // conv_from_segment contract: // 1. takes @@ -149,8 +150,13 @@ impl Intf { // - if the string falls outside bounds: // for i64 output, the int minimum or int max (depending on sign) // for u64 output, the u64 max in the output radix - fn conv_from_segment(segment: &str, radix_in: Base, fchar: char, sign: i8) -> FormatPrimitive { - match fchar { + fn conv_from_segment( + segment: &str, + radix_in: Base, + field_char: char, + sign: i8, + ) -> FormatPrimitive { + match field_char { 'i' | 'd' => match i64::from_str_radix(segment, radix_in as u32) { Ok(i) => { let mut fmt_prim: FormatPrimitive = Default::default(); @@ -160,13 +166,13 @@ impl Intf { fmt_prim.pre_decimal = Some(format!("{}", i)); fmt_prim } - Err(_) => Intf::get_max(fchar, sign), + Err(_) => Intf::get_max(field_char, sign), }, _ => match u64::from_str_radix(segment, radix_in as u32) { Ok(u) => { let mut fmt_prim: FormatPrimitive = Default::default(); let u_f = if sign == -1 { u64::MAX - (u - 1) } else { u }; - fmt_prim.pre_decimal = Some(match fchar { + fmt_prim.pre_decimal = Some(match field_char { 'X' => format!("{:X}", u_f), 'x' => format!("{:x}", u_f), 'o' => format!("{:o}", u_f), @@ -174,7 +180,7 @@ impl Intf { }); fmt_prim } - Err(_) => Intf::get_max(fchar, sign), + Err(_) => Intf::get_max(field_char, sign), }, } } @@ -183,17 +189,17 @@ impl Formatter for Intf { fn get_primitive( &self, field: &FormatField, - inprefix: &InPrefix, + initial_prefix: &InitialPrefix, str_in: &str, ) -> Option { - let begin = inprefix.offset; + let begin = initial_prefix.offset; // get information about the string. see Intf::Analyze // def above. let convert_hints = Intf::analyze( str_in, *field.field_char == 'i' || *field.field_char == 'd', - inprefix, + initial_prefix, ); // We always will have a format primitive to return Some(if convert_hints.len_digits == 0 || convert_hints.is_zero { @@ -209,22 +215,22 @@ impl Formatter for Intf { 'x' | 'X' => Base::Hex, /* 'o' | */ _ => Base::Octal, }; - let radix_mismatch = !radix_out.eq(&inprefix.radix_in); - let decr_from_max: bool = inprefix.sign == -1 && *field.field_char != 'i'; + let radix_mismatch = !radix_out.eq(&initial_prefix.radix_in); + let decrease_from_max: bool = initial_prefix.sign == -1 && *field.field_char != 'i'; let end = begin + convert_hints.len_digits as usize; // convert to int if any one of these is true: // - number of digits in int indicates it may be past max // - we're subtracting from the max // - we're converting the base - if convert_hints.check_past_max || decr_from_max || radix_mismatch { + if convert_hints.check_past_max || decrease_from_max || radix_mismatch { // radix of in and out is the same. let segment = String::from(&str_in[begin..end]); Intf::conv_from_segment( &segment, - inprefix.radix_in.clone(), + initial_prefix.radix_in.clone(), *field.field_char, - inprefix.sign, + initial_prefix.sign, ) } else { // otherwise just do a straight string copy. @@ -233,20 +239,20 @@ impl Formatter for Intf { // this is here and not earlier because // zero doesn't get a sign, and conv_from_segment // creates its format primitive separately - if inprefix.sign == -1 && *field.field_char == 'i' { + if initial_prefix.sign == -1 && *field.field_char == 'i' { fmt_prim.prefix = Some(String::from("-")); } fmt_prim.pre_decimal = Some(String::from(&str_in[begin..end])); fmt_prim } } else { - Intf::get_max(*field.field_char, inprefix.sign) + Intf::get_max(*field.field_char, initial_prefix.sign) }) } fn primitive_to_str(&self, prim: &FormatPrimitive, field: FormatField) -> String { - let mut finalstr: String = String::new(); + let mut final_str: String = String::new(); if let Some(ref prefix) = prim.prefix { - finalstr.push_str(&prefix); + final_str.push_str(&prefix); } // integral second fields is zero-padded minimum-width // which gets handled before general minimum-width @@ -256,11 +262,11 @@ impl Formatter for Intf { let mut i = min; let len = pre_decimal.len() as u32; while i > len { - finalstr.push('0'); + final_str.push('0'); i -= 1; } } - finalstr.push_str(&pre_decimal); + final_str.push_str(&pre_decimal); } None => { panic!( @@ -269,6 +275,6 @@ impl Formatter for Intf { ); } } - finalstr + final_str } } diff --git a/src/uu/printf/src/tokenize/num_format/formatters/mod.rs b/src/uu/printf/src/tokenize/num_format/formatters/mod.rs index ccbcdb1e7..e23230071 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/mod.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/mod.rs @@ -1,4 +1,4 @@ -// spell-checker:ignore (ToDO) conv cninetyninehexfloatf floatf intf scif +// spell-checker:ignore (vars) charf cninetyninehexfloatf decf floatf intf scif strf Cninety mod base_conv; pub mod cninetyninehexfloatf; diff --git a/src/uu/printf/src/tokenize/num_format/formatters/scif.rs b/src/uu/printf/src/tokenize/num_format/formatters/scif.rs index ebac1565e..c46c7d423 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/scif.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/scif.rs @@ -1,8 +1,8 @@ -// spell-checker:ignore (ToDO) conv intf strf floatf scif charf fieldtype vals subparser unescaping submodule Cninety inprefix +// spell-checker:ignore (vars) charf cninetyninehexfloatf decf floatf intf scif strf Cninety //! formatter for %e %E scientific notation subs use super::super::format_field::FormatField; -use super::super::formatter::{FormatPrimitive, Formatter, InPrefix}; +use super::super::formatter::{FormatPrimitive, Formatter, InitialPrefix}; use super::float_common::{get_primitive_dec, primitive_to_str_common, FloatAnalysis}; pub struct Scif; @@ -16,20 +16,20 @@ impl Formatter for Scif { fn get_primitive( &self, field: &FormatField, - inprefix: &InPrefix, + initial_prefix: &InitialPrefix, str_in: &str, ) -> Option { let second_field = field.second_field.unwrap_or(6) + 1; let analysis = FloatAnalysis::analyze( str_in, - inprefix, + initial_prefix, Some(second_field as usize + 1), None, false, ); let f = get_primitive_dec( - inprefix, - &str_in[inprefix.offset..], + initial_prefix, + &str_in[initial_prefix.offset..], &analysis, second_field as usize, Some(*field.field_char == 'E'), diff --git a/src/uu/printf/src/tokenize/num_format/num_format.rs b/src/uu/printf/src/tokenize/num_format/num_format.rs index 812f51b5a..a8a60cc57 100644 --- a/src/uu/printf/src/tokenize/num_format/num_format.rs +++ b/src/uu/printf/src/tokenize/num_format/num_format.rs @@ -1,12 +1,14 @@ -// spell-checker:ignore (ToDO) conv intf strf floatf scif charf fieldtype vals subparser unescaping submodule Cninety qchar topchar structs fmtr fchar inprefix devs octals cninetyninehexfloatf +// spell-checker:ignore (vars) charf cninetyninehexfloatf decf floatf intf scif strf Cninety //! handles creating printed output for numeric substitutions +// spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety + use std::env; use std::vec::Vec; use super::format_field::{FieldType, FormatField}; -use super::formatter::{Base, FormatPrimitive, Formatter, InPrefix}; +use super::formatter::{Base, FormatPrimitive, Formatter, InitialPrefix}; use super::formatters::cninetyninehexfloatf::CninetyNineHexFloatf; use super::formatters::decf::Decf; use super::formatters::floatf::Floatf; @@ -46,8 +48,8 @@ fn get_provided(str_in_opt: Option<&String>) -> Option { match str_in_opt { Some(str_in) => { let mut byte_it = str_in.bytes(); - if let Some(qchar) = byte_it.next() { - match qchar { + if let Some(ch) = byte_it.next() { + match ch { C_S_QUOTE | C_D_QUOTE => { Some(match byte_it.next() { Some(second_byte) => { @@ -62,7 +64,7 @@ fn get_provided(str_in_opt: Option<&String>) -> Option { } // no byte after quote None => { - let so_far = (qchar as u8 as char).to_string(); + let so_far = (ch as u8 as char).to_string(); warn_expected_numeric(&so_far); 0_u8 } @@ -84,30 +86,30 @@ fn get_provided(str_in_opt: Option<&String>) -> Option { // a base, // and an offset for index after all // initial spacing, sign, base prefix, and leading zeroes -fn get_inprefix(str_in: &str, field_type: &FieldType) -> InPrefix { +fn get_initial_prefix(str_in: &str, field_type: &FieldType) -> InitialPrefix { let mut str_it = str_in.chars(); - let mut ret = InPrefix { + let mut ret = InitialPrefix { radix_in: Base::Ten, sign: 1, offset: 0, }; - let mut topchar = str_it.next(); - // skip spaces and ensure topchar is the first non-space char + let mut top_char = str_it.next(); + // skip spaces and ensure top_char is the first non-space char // (or None if none exists) - while let Some(' ') = topchar { + while let Some(' ') = top_char { ret.offset += 1; - topchar = str_it.next(); + top_char = str_it.next(); } // parse sign - match topchar { + match top_char { Some('+') => { ret.offset += 1; - topchar = str_it.next(); + top_char = str_it.next(); } Some('-') => { ret.sign = -1; ret.offset += 1; - topchar = str_it.next(); + top_char = str_it.next(); } _ => {} } @@ -125,7 +127,7 @@ fn get_inprefix(str_in: &str, field_type: &FieldType) -> InPrefix { // final offset. If the zero could be before // a decimal point we don't move past the zero. let mut is_hex = false; - if Some('0') == topchar { + if Some('0') == top_char { if let Some(base) = str_it.next() { // lead zeroes can only exist in // octal and hex base @@ -152,7 +154,7 @@ fn get_inprefix(str_in: &str, field_type: &FieldType) -> InPrefix { let mut first = true; for ch_zero in str_it { // see notes on offset above: - // this is why the offset for octals and decimals + // this is why the offset for octal and decimal numbers // that reach this branch is 1 even though // they have already eaten the characters '00' // this is also why when hex encounters its @@ -194,21 +196,21 @@ fn get_inprefix(str_in: &str, field_type: &FieldType) -> InPrefix { // if it is a numeric field, passing the field details // and an iterator to the argument pub fn num_format(field: &FormatField, in_str_opt: Option<&String>) -> Option { - let fchar = field.field_char; + let field_char = field.field_char; // num format mainly operates by further delegating to one of // several Formatter structs depending on the field // see formatter.rs for more details // to do switch to static dispatch - let fmtr: Box = match *field.field_type { + let formatter: Box = match *field.field_type { FieldType::Intf => Box::new(Intf::new()), FieldType::Floatf => Box::new(Floatf::new()), FieldType::CninetyNineHexFloatf => Box::new(CninetyNineHexFloatf::new()), FieldType::Scif => Box::new(Scif::new()), FieldType::Decf => Box::new(Decf::new()), _ => { - panic!("asked to do num format with non-num fieldtype"); + panic!("asked to do num format with non-num field type"); } }; let prim_opt= @@ -216,7 +218,7 @@ pub fn num_format(field: &FormatField, in_str_opt: Option<&String>) -> Option { tmp.pre_decimal = Some( format!("{}", provided_num)); @@ -231,11 +233,11 @@ pub fn num_format(field: &FormatField, in_str_opt: Option<&String>) -> Option { let as_str = format!("{}", provided_num); - let inprefix = get_inprefix( + let initial_prefix = get_initial_prefix( &as_str, &field.field_type ); - tmp=fmtr.get_primitive(field, &inprefix, &as_str) + tmp=formatter.get_primitive(field, &initial_prefix, &as_str) .expect("err during default provided num"); }, _ => { @@ -254,14 +256,14 @@ pub fn num_format(field: &FormatField, in_str_opt: Option<&String>) -> Option FieldType::Charf, _ => { // should be unreachable. - println!("Invalid fieldtype"); + println!("Invalid field type"); exit(cli::EXIT_ERR); } }; @@ -130,7 +130,7 @@ impl SubParser { } } fn build_token(parser: SubParser) -> Box { - // not a self method so as to allow move of subparser vals. + // not a self method so as to allow move of sub-parser vals. // return new Sub struct as token let t: Box = Box::new(Sub::new( if parser.min_width_is_asterisk { @@ -354,7 +354,7 @@ impl token::Token for Sub { // field char let pre_min_width_opt: Option = match *field.field_type { // if %s just return arg - // if %b use UnescapedText module's unescaping-fn + // if %b use UnescapedText module's unescape-fn // if %c return first char of arg FieldType::Strf | FieldType::Charf => { match pf_arg { diff --git a/src/uu/ptx/src/main.rs b/src/uu/ptx/src/main.rs index 0b235443a..b627b801f 100644 --- a/src/uu/ptx/src/main.rs +++ b/src/uu/ptx/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_ptx); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_ptx); diff --git a/src/uu/ptx/src/ptx.rs b/src/uu/ptx/src/ptx.rs index a17f7c810..5b0c35093 100644 --- a/src/uu/ptx/src/ptx.rs +++ b/src/uu/ptx/src/ptx.rs @@ -246,7 +246,7 @@ fn read_input(input_files: &[String], config: &Config) -> FileMap { file_map } -/// Go through every lines in the input files and record each match occurance as a `WordRef`. +/// Go through every lines in the input files and record each match occurrence as a `WordRef`. fn create_word_set(config: &Config, filter: &WordFilter, file_map: &FileMap) -> BTreeSet { let reg = Regex::new(&filter.word_regex).unwrap(); let ref_reg = Regex::new(&config.context_regex).unwrap(); @@ -412,7 +412,7 @@ fn get_output_chunks( 0, ) as usize; - // the tail chunk takes text starting from where the after chunk ends (with whitespaces trimmed). + // the tail chunk takes text starting from where the after chunk ends (with whitespace trimmed). let (tail_beg, _) = trim_idx(all_after, after_end, all_after.len()); // end = begin + max length @@ -493,10 +493,10 @@ fn format_tex_line( output.push_str(&format!("\\{} ", config.macro_name)); let all_before = if config.input_ref { let before = &line[0..word_ref.position]; - let before_start_trimoff = + let before_start_trim_offset = word_ref.position - before.trim_start_matches(reference).trim_start().len(); let before_end_index = before.len(); - &chars_line[before_start_trimoff..cmp::max(before_end_index, before_start_trimoff)] + &chars_line[before_start_trim_offset..cmp::max(before_end_index, before_start_trim_offset)] } else { let before_chars_trim_idx = (0, word_ref.position); &chars_line[before_chars_trim_idx.0..before_chars_trim_idx.1] @@ -536,10 +536,10 @@ fn format_roff_line( output.push_str(&format!(".{}", config.macro_name)); let all_before = if config.input_ref { let before = &line[0..word_ref.position]; - let before_start_trimoff = + let before_start_trim_offset = word_ref.position - before.trim_start_matches(reference).trim_start().len(); let before_end_index = before.len(); - &chars_line[before_start_trimoff..cmp::max(before_end_index, before_start_trimoff)] + &chars_line[before_start_trim_offset..cmp::max(before_end_index, before_start_trim_offset)] } else { let before_chars_trim_idx = (0, word_ref.position); &chars_line[before_chars_trim_idx.0..before_chars_trim_idx.1] diff --git a/src/uu/pwd/src/main.rs b/src/uu/pwd/src/main.rs index 4445b7891..c5716d2c9 100644 --- a/src/uu/pwd/src/main.rs +++ b/src/uu/pwd/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_pwd); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_pwd); diff --git a/src/uu/readlink/src/main.rs b/src/uu/readlink/src/main.rs index e5aab3cb6..651fd73ca 100644 --- a/src/uu/readlink/src/main.rs +++ b/src/uu/readlink/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_readlink); // spell-checker:ignore procs uucore readlink +uucore_procs::main!(uu_readlink); diff --git a/src/uu/realpath/src/main.rs b/src/uu/realpath/src/main.rs index 3a74bc5f6..8b8a8dc5e 100644 --- a/src/uu/realpath/src/main.rs +++ b/src/uu/realpath/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_realpath); // spell-checker:ignore procs uucore realpath +uucore_procs::main!(uu_realpath); diff --git a/src/uu/relpath/src/main.rs b/src/uu/relpath/src/main.rs index a5f866bb2..22aa68d53 100644 --- a/src/uu/relpath/src/main.rs +++ b/src/uu/relpath/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_relpath); // spell-checker:ignore procs uucore relpath +uucore_procs::main!(uu_relpath); diff --git a/src/uu/rm/src/main.rs b/src/uu/rm/src/main.rs index ebb998c39..960867359 100644 --- a/src/uu/rm/src/main.rs +++ b/src/uu/rm/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_rm); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_rm); diff --git a/src/uu/rmdir/src/main.rs b/src/uu/rmdir/src/main.rs index ab1939b4a..92ff22c07 100644 --- a/src/uu/rmdir/src/main.rs +++ b/src/uu/rmdir/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_rmdir); // spell-checker:ignore procs uucore rmdir +uucore_procs::main!(uu_rmdir); diff --git a/src/uu/seq/src/main.rs b/src/uu/seq/src/main.rs index c984ed61a..266ac5d11 100644 --- a/src/uu/seq/src/main.rs +++ b/src/uu/seq/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_seq); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_seq); diff --git a/src/uu/shred/src/main.rs b/src/uu/shred/src/main.rs index 2880499eb..ea7a42f65 100644 --- a/src/uu/shred/src/main.rs +++ b/src/uu/shred/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_shred); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_shred); diff --git a/src/uu/shred/src/shred.rs b/src/uu/shred/src/shred.rs index 15a4eff26..e371ad6b2 100644 --- a/src/uu/shred/src/shred.rs +++ b/src/uu/shred/src/shred.rs @@ -6,7 +6,7 @@ // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. -// spell-checker:ignore (ToDO) NAMESET FILESIZE fstab coeff journaling writeback REiser journaled +// spell-checker:ignore (words) writeback wipesync use clap::{App, Arg}; use rand::{Rng, ThreadRng}; @@ -25,7 +25,7 @@ extern crate uucore; static NAME: &str = "shred"; static VERSION_STR: &str = "1.0.0"; const BLOCK_SIZE: usize = 512; -const NAMESET: &str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_."; +const NAME_CHARSET: &str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_."; // Patterns as shown in the GNU coreutils shred implementation const PATTERNS: [&[u8]; 22] = [ @@ -59,10 +59,10 @@ enum PassType<'a> { Random, } -// Used to generate all possible filenames of a certain length using NAMESET as an alphabet +// Used to generate all possible filenames of a certain length using NAME_CHARSET as an alphabet struct FilenameGenerator { name_len: usize, - nameset_indices: RefCell>, // Store the indices of the letters of our filename in NAMESET + name_charset_indices: RefCell>, // Store the indices of the letters of our filename in NAME_CHARSET exhausted: Cell, } @@ -71,7 +71,7 @@ impl FilenameGenerator { let indices: Vec = vec![0; name_len]; FilenameGenerator { name_len, - nameset_indices: RefCell::new(indices), + name_charset_indices: RefCell::new(indices), exhausted: Cell::new(false), } } @@ -85,25 +85,25 @@ impl Iterator for FilenameGenerator { return None; } - let mut nameset_indices = self.nameset_indices.borrow_mut(); + let mut name_charset_indices = self.name_charset_indices.borrow_mut(); // Make the return value, then increment let mut ret = String::new(); - for i in nameset_indices.iter() { - let c: char = NAMESET.chars().nth(*i).unwrap(); + for i in name_charset_indices.iter() { + let c: char = NAME_CHARSET.chars().nth(*i).unwrap(); ret.push(c); } - if nameset_indices[0] == NAMESET.len() - 1 { + if name_charset_indices[0] == NAME_CHARSET.len() - 1 { self.exhausted.set(true) } // Now increment the least significant index for i in (0..self.name_len).rev() { - if nameset_indices[i] == NAMESET.len() - 1 { - nameset_indices[i] = 0; // Carry the 1 + if name_charset_indices[i] == NAME_CHARSET.len() - 1 { + name_charset_indices[i] = 0; // Carry the 1 continue; } else { - nameset_indices[i] += 1; + name_charset_indices[i] += 1; break; } } @@ -233,7 +233,7 @@ static AFTER_HELP: &str = assumption. The following are examples of file systems on which shred is\n\ not effective, or is not guaranteed to be effective in all file system modes:\n\ \n\ - * log-structured or journaled file systems, such as those supplied with\n\ + * log-structured or journal file systems, such as those supplied with\n\ AIX and Solaris (and JFS, ReiserFS, XFS, Ext3, etc.)\n\ \n\ * file systems that write redundant data and carry on even if some writes\n\ @@ -250,7 +250,7 @@ static AFTER_HELP: &str = and shred is thus of limited effectiveness) only in data=journal mode,\n\ which journals file data in addition to just metadata. In both the\n\ data=ordered (default) and data=writeback modes, shred works as usual.\n\ - Ext3 journaling modes can be changed by adding the data=something option\n\ + Ext3 journal modes can be changed by adding the data=something option\n\ to the mount options for a particular file system in the /etc/fstab file,\n\ as documented in the mount man page (man mount).\n\ \n\ @@ -412,7 +412,7 @@ fn get_size(size_str_opt: Option) -> Option { _ => 1u64, }; - let coeff = match size_str.parse::() { + let coefficient = match size_str.parse::() { Ok(u) => u, Err(_) => { println!("{}: {}: Invalid file size", NAME, size_str_opt.unwrap()); @@ -420,7 +420,7 @@ fn get_size(size_str_opt: Option) -> Option { } }; - Some(coeff * unit) + Some(coefficient * unit) } fn pass_name(pass_type: PassType) -> String { diff --git a/src/uu/shuf/src/main.rs b/src/uu/shuf/src/main.rs index 1ecff5d21..fc6e2b4ae 100644 --- a/src/uu/shuf/src/main.rs +++ b/src/uu/shuf/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_shuf); // spell-checker:ignore procs uucore shuf +uucore_procs::main!(uu_shuf); diff --git a/src/uu/sleep/src/main.rs b/src/uu/sleep/src/main.rs index 46ecd0969..16c3100aa 100644 --- a/src/uu/sleep/src/main.rs +++ b/src/uu/sleep/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_sleep); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_sleep); diff --git a/src/uu/sort/BENCHMARKING.md b/src/uu/sort/BENCHMARKING.md index 560d6b438..77186318a 100644 --- a/src/uu/sort/BENCHMARKING.md +++ b/src/uu/sort/BENCHMARKING.md @@ -1,5 +1,7 @@ # Benchmarking sort + + Most of the time when sorting is spent comparing lines. The comparison functions however differ based on which arguments are passed to `sort`, therefore it is important to always benchmark multiple scenarios. This is an overview over what was benchmarked, and if you make changes to `sort`, you are encouraged to check @@ -96,7 +98,7 @@ When invoked with -c, we simply check if the input is already ordered. The input Try to run the above benchmarks by piping the input through stdin (standard input) and redirect the output through stdout (standard output): -- Remove the input file from the arguments and add `cat [inputfile] | ` at the beginning. +- Remove the input file from the arguments and add `cat [input_file] | ` at the beginning. - Remove `-o output.txt` and add `> output.txt` at the end. Example: `hyperfine "target/release/coreutils sort shuffled_numbers.txt -n -o output.txt"` becomes diff --git a/src/uu/sort/src/main.rs b/src/uu/sort/src/main.rs index a59375b2f..ab463776d 100644 --- a/src/uu/sort/src/main.rs +++ b/src/uu/sort/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_sort); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_sort); diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index a3b79e5d7..ab3b06451 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -11,7 +11,8 @@ // https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sort.html // https://www.gnu.org/software/coreutils/manual/html_node/sort-invocation.html -// spell-checker:ignore (ToDO) outfile nondictionary +// spell-checker:ignore (misc) HFKJFK Mbdfhn + #[macro_use] extern crate uucore; @@ -143,7 +144,7 @@ pub struct GlobalSettings { ignore_non_printing: bool, merge: bool, reverse: bool, - outfile: Option, + output_file: Option, stable: bool, unique: bool, check: bool, @@ -187,7 +188,7 @@ impl GlobalSettings { } fn out_writer(&self) -> BufWriter> { - match self.outfile { + match self.output_file { Some(ref filename) => match File::create(Path::new(&filename)) { Ok(f) => BufWriter::new(Box::new(f) as Box), Err(e) => { @@ -211,7 +212,7 @@ impl Default for GlobalSettings { ignore_non_printing: false, merge: false, reverse: false, - outfile: None, + output_file: None, stable: false, unique: false, check: false, @@ -1168,7 +1169,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { settings.ignore_blanks = matches.is_present(OPT_IGNORE_BLANKS); - settings.outfile = matches.value_of(OPT_OUTPUT).map(String::from); + settings.output_file = matches.value_of(OPT_OUTPUT).map(String::from); settings.reverse = matches.is_present(OPT_REVERSE); settings.stable = matches.is_present(OPT_STABLE); settings.unique = matches.is_present(OPT_UNIQUE); diff --git a/src/uu/split/src/main.rs b/src/uu/split/src/main.rs index 2f0640db4..87f15f529 100644 --- a/src/uu/split/src/main.rs +++ b/src/uu/split/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_split); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_split); diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 39bd577cb..85ed5f183 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -157,13 +157,13 @@ pub fn uumain(args: impl uucore::Args) -> i32 { settings.verbose = matches.occurrences_of("verbose") > 0; // check that the user is not specifying more than one strategy - // note: right now, this exact behaviour cannot be handled by ArgGroup since ArgGroup + // note: right now, this exact behavior cannot be handled by ArgGroup since ArgGroup // considers a default value Arg as "defined" let explicit_strategies = vec![OPT_LINE_BYTES, OPT_LINES, OPT_BYTES] .into_iter() - .fold(0, |count, strat| { - if matches.occurrences_of(strat) > 0 { + .fold(0, |count, strategy| { + if matches.occurrences_of(strategy) > 0 { count + 1 } else { count @@ -177,10 +177,10 @@ pub fn uumain(args: impl uucore::Args) -> i32 { settings.strategy = String::from(OPT_LINES); settings.strategy_param = matches.value_of(OPT_LINES).unwrap().to_owned(); // take any (other) defined strategy - for strat in vec![OPT_LINE_BYTES, OPT_BYTES].into_iter() { - if matches.occurrences_of(strat) > 0 { - settings.strategy = String::from(strat); - settings.strategy_param = matches.value_of(strat).unwrap().to_owned(); + for strategy in vec![OPT_LINE_BYTES, OPT_BYTES].into_iter() { + if matches.occurrences_of(strategy) > 0 { + settings.strategy = String::from(strategy); + settings.strategy_param = matches.value_of(strategy).unwrap().to_owned(); } } diff --git a/src/uu/stat/src/main.rs b/src/uu/stat/src/main.rs index 6e483c850..839eff7de 100644 --- a/src/uu/stat/src/main.rs +++ b/src/uu/stat/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_stat); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_stat); diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index 582d59841..403134b4b 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -5,8 +5,6 @@ // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. -// spell-checker:ignore (ToDO) showfs otype fmtstr prec ftype blocksize nlink rdev fnodes fsid namelen blksize inodes fstype iosize statfs gnulib NBLOCKSIZE - #[macro_use] extern crate uucore; use uucore::entries; @@ -208,7 +206,7 @@ pub fn group_num(s: &str) -> Cow { pub struct Stater { follow: bool, - showfs: bool, + show_fs: bool, from_user: bool, files: Vec, mount_list: Option>, @@ -217,7 +215,7 @@ pub struct Stater { } #[allow(clippy::cognitive_complexity)] -fn print_it(arg: &str, otype: OutputType, flag: u8, width: usize, precision: i32) { +fn print_it(arg: &str, output_type: OutputType, flag: u8, width: usize, precision: i32) { // If the precision is given as just '.', the precision is taken to be zero. // A negative precision is taken as if the precision were omitted. // This gives the minimum number of digits to appear for d, i, o, u, x, and X conversions, @@ -248,7 +246,7 @@ fn print_it(arg: &str, otype: OutputType, flag: u8, width: usize, precision: i32 // By default, a sign is used only for negative numbers. // A + overrides a space if both are used. - if otype == OutputType::Unknown { + if output_type == OutputType::Unknown { return print!("?"); } @@ -262,7 +260,7 @@ fn print_it(arg: &str, otype: OutputType, flag: u8, width: usize, precision: i32 let has_sign = has!(flag, F_SIGN) || has!(flag, F_SPACE); let should_alter = has!(flag, F_ALTER); - let prefix = match otype { + let prefix = match output_type { OutputType::UnsignedOct => "0", OutputType::UnsignedHex => "0x", OutputType::Integer => { @@ -275,7 +273,7 @@ fn print_it(arg: &str, otype: OutputType, flag: u8, width: usize, precision: i32 _ => "", }; - match otype { + match output_type { OutputType::Str => { let limit = cmp::min(precision, arg.len() as i32); let s: &str = if limit >= 0 { @@ -334,10 +332,10 @@ fn print_it(arg: &str, otype: OutputType, flag: u8, width: usize, precision: i32 } impl Stater { - pub fn generate_tokens(fmtstr: &str, use_printf: bool) -> Result, String> { + pub fn generate_tokens(format_str: &str, use_printf: bool) -> Result, String> { let mut tokens = Vec::new(); - let bound = fmtstr.len(); - let chars = fmtstr.chars().collect::>(); + let bound = format_str.len(); + let chars = format_str.chars().collect::>(); let mut i = 0_usize; while i < bound { match chars[i] { @@ -370,32 +368,32 @@ impl Stater { } i += 1; } - check_bound!(fmtstr, bound, old, i); + check_bound!(format_str, bound, old, i); let mut width = 0_usize; let mut precision = -1_i32; let mut j = i; - if let Some((field_width, offset)) = fmtstr[j..].scan_num::() { + if let Some((field_width, offset)) = format_str[j..].scan_num::() { width = field_width; j += offset; } - check_bound!(fmtstr, bound, old, j); + check_bound!(format_str, bound, old, j); if chars[j] == '.' { j += 1; - check_bound!(fmtstr, bound, old, j); + check_bound!(format_str, bound, old, j); - match fmtstr[j..].scan_num::() { - Some((prec, offset)) => { - if prec >= 0 { - precision = prec; + match format_str[j..].scan_num::() { + Some((value, offset)) => { + if value >= 0 { + precision = value; } j += offset; } None => precision = 0, } - check_bound!(fmtstr, bound, old, j); + check_bound!(format_str, bound, old, j); } i = j; @@ -418,7 +416,7 @@ impl Stater { } match chars[i] { 'x' if i + 1 < bound => { - if let Some((c, offset)) = fmtstr[i + 1..].scan_char(16) { + if let Some((c, offset)) = format_str[i + 1..].scan_char(16) { tokens.push(Token::Char(c)); i += offset; } else { @@ -427,7 +425,7 @@ impl Stater { } } '0'..='7' => { - let (c, offset) = fmtstr[i..].scan_char(8).unwrap(); + let (c, offset) = format_str[i..].scan_char(8).unwrap(); tokens.push(Token::Char(c)); i += offset - 1; } @@ -452,7 +450,7 @@ impl Stater { } i += 1; } - if !use_printf && !fmtstr.ends_with('\n') { + if !use_printf && !format_str.ends_with('\n') { tokens.push(Token::Char('\n')); } Ok(tokens) @@ -464,7 +462,7 @@ impl Stater { .map(|v| v.map(ToString::to_string).collect()) .unwrap_or_default(); - let fmtstr = if matches.is_present(options::PRINTF) { + let format_str = if matches.is_present(options::PRINTF) { matches .value_of(options::PRINTF) .expect("Invalid format string") @@ -474,17 +472,19 @@ impl Stater { let use_printf = matches.is_present(options::PRINTF); let terse = matches.is_present(options::TERSE); - let showfs = matches.is_present(options::FILE_SYSTEM); + let show_fs = matches.is_present(options::FILE_SYSTEM); - let default_tokens = if fmtstr.is_empty() { - Stater::generate_tokens(&Stater::default_fmt(showfs, terse, false), use_printf).unwrap() + let default_tokens = if format_str.is_empty() { + Stater::generate_tokens(&Stater::default_format(show_fs, terse, false), use_printf) + .unwrap() } else { - Stater::generate_tokens(&fmtstr, use_printf)? + Stater::generate_tokens(&format_str, use_printf)? }; let default_dev_tokens = - Stater::generate_tokens(&Stater::default_fmt(showfs, terse, true), use_printf).unwrap(); + Stater::generate_tokens(&Stater::default_format(show_fs, terse, true), use_printf) + .unwrap(); - let mount_list = if showfs { + let mount_list = if show_fs { // mount points aren't displayed when showing filesystem information None } else { @@ -500,8 +500,8 @@ impl Stater { Ok(Stater { follow: matches.is_present(options::DEREFERENCE), - showfs, - from_user: !fmtstr.is_empty(), + show_fs, + from_user: !format_str.is_empty(), files, default_tokens, default_dev_tokens, @@ -533,7 +533,7 @@ impl Stater { } fn do_stat(&self, file: &str) -> i32 { - if !self.showfs { + if !self.show_fs { let result = if self.follow { fs::metadata(file) } else { @@ -541,13 +541,14 @@ impl Stater { }; match result { Ok(meta) => { - let ftype = meta.file_type(); - let tokens = - if self.from_user || !(ftype.is_char_device() || ftype.is_block_device()) { - &self.default_tokens - } else { - &self.default_dev_tokens - }; + let file_type = meta.file_type(); + let tokens = if self.from_user + || !(file_type.is_char_device() || file_type.is_block_device()) + { + &self.default_tokens + } else { + &self.default_dev_tokens + }; for t in tokens.iter() { match *t { @@ -559,91 +560,91 @@ impl Stater { format, } => { let arg: String; - let otype: OutputType; + let output_type: OutputType; match format { // access rights in octal 'a' => { arg = format!("{:o}", 0o7777 & meta.mode()); - otype = OutputType::UnsignedOct; + output_type = OutputType::UnsignedOct; } // access rights in human readable form 'A' => { arg = display_permissions(&meta, true); - otype = OutputType::Str; + output_type = OutputType::Str; } // number of blocks allocated (see %B) 'b' => { arg = format!("{}", meta.blocks()); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // the size in bytes of each block reported by %b // FIXME: blocksize differs on various platform - // See coreutils/gnulib/lib/stat-size.h ST_NBLOCKSIZE + // See coreutils/gnulib/lib/stat-size.h ST_NBLOCKSIZE // spell-checker:disable-line 'B' => { // the size in bytes of each block reported by %b arg = format!("{}", 512); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // device number in decimal 'd' => { arg = format!("{}", meta.dev()); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // device number in hex 'D' => { arg = format!("{:x}", meta.dev()); - otype = OutputType::UnsignedHex; + output_type = OutputType::UnsignedHex; } // raw mode in hex 'f' => { arg = format!("{:x}", meta.mode()); - otype = OutputType::UnsignedHex; + output_type = OutputType::UnsignedHex; } // file type 'F' => { arg = pretty_filetype(meta.mode() as mode_t, meta.len()) .to_owned(); - otype = OutputType::Str; + output_type = OutputType::Str; } // group ID of owner 'g' => { arg = format!("{}", meta.gid()); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // group name of owner 'G' => { arg = entries::gid2grp(meta.gid()) .unwrap_or_else(|_| "UNKNOWN".to_owned()); - otype = OutputType::Str; + output_type = OutputType::Str; } // number of hard links 'h' => { arg = format!("{}", meta.nlink()); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // inode number 'i' => { arg = format!("{}", meta.ino()); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // mount point 'm' => { arg = self.find_mount_point(file).unwrap(); - otype = OutputType::Str; + output_type = OutputType::Str; } // file name 'n' => { arg = file.to_owned(); - otype = OutputType::Str; + output_type = OutputType::Str; } // quoted file name with dereference if symbolic link 'N' => { - if ftype.is_symlink() { + if file_type.is_symlink() { let dst = match fs::read_link(file) { Ok(path) => path, Err(e) => { @@ -659,91 +660,91 @@ impl Stater { } else { arg = file.to_string(); } - otype = OutputType::Str; + output_type = OutputType::Str; } // optimal I/O transfer size hint 'o' => { arg = format!("{}", meta.blksize()); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // total size, in bytes 's' => { arg = format!("{}", meta.len()); - otype = OutputType::Integer; + output_type = OutputType::Integer; } // major device type in hex, for character/block device special // files 't' => { arg = format!("{:x}", meta.rdev() >> 8); - otype = OutputType::UnsignedHex; + output_type = OutputType::UnsignedHex; } // minor device type in hex, for character/block device special // files 'T' => { arg = format!("{:x}", meta.rdev() & 0xff); - otype = OutputType::UnsignedHex; + output_type = OutputType::UnsignedHex; } // user ID of owner 'u' => { arg = format!("{}", meta.uid()); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // user name of owner 'U' => { arg = entries::uid2usr(meta.uid()) .unwrap_or_else(|_| "UNKNOWN".to_owned()); - otype = OutputType::Str; + output_type = OutputType::Str; } // time of file birth, human-readable; - if unknown 'w' => { arg = meta.pretty_birth(); - otype = OutputType::Str; + output_type = OutputType::Str; } // time of file birth, seconds since Epoch; 0 if unknown 'W' => { arg = meta.birth(); - otype = OutputType::Integer; + output_type = OutputType::Integer; } // time of last access, human-readable 'x' => { arg = pretty_time(meta.atime(), meta.atime_nsec()); - otype = OutputType::Str; + output_type = OutputType::Str; } // time of last access, seconds since Epoch 'X' => { arg = format!("{}", meta.atime()); - otype = OutputType::Integer; + output_type = OutputType::Integer; } // time of last data modification, human-readable 'y' => { arg = pretty_time(meta.mtime(), meta.mtime_nsec()); - otype = OutputType::Str; + output_type = OutputType::Str; } // time of last data modification, seconds since Epoch 'Y' => { arg = format!("{}", meta.mtime()); - otype = OutputType::Str; + output_type = OutputType::Str; } // time of last status change, human-readable 'z' => { arg = pretty_time(meta.ctime(), meta.ctime_nsec()); - otype = OutputType::Str; + output_type = OutputType::Str; } // time of last status change, seconds since Epoch 'Z' => { arg = format!("{}", meta.ctime()); - otype = OutputType::Integer; + output_type = OutputType::Integer; } _ => { arg = "?".to_owned(); - otype = OutputType::Unknown; + output_type = OutputType::Unknown; } } - print_it(&arg, otype, flag, width, precision); + print_it(&arg, output_type, flag, width, precision); } } } @@ -768,75 +769,75 @@ impl Stater { format, } => { let arg: String; - let otype: OutputType; + let output_type: OutputType; match format { // free blocks available to non-superuser 'a' => { arg = format!("{}", meta.avail_blocks()); - otype = OutputType::Integer; + output_type = OutputType::Integer; } // total data blocks in file system 'b' => { arg = format!("{}", meta.total_blocks()); - otype = OutputType::Integer; + output_type = OutputType::Integer; } // total file nodes in file system 'c' => { - arg = format!("{}", meta.total_fnodes()); - otype = OutputType::Unsigned; + arg = format!("{}", meta.total_file_nodes()); + output_type = OutputType::Unsigned; } // free file nodes in file system 'd' => { - arg = format!("{}", meta.free_fnodes()); - otype = OutputType::Integer; + arg = format!("{}", meta.free_file_nodes()); + output_type = OutputType::Integer; } // free blocks in file system 'f' => { arg = format!("{}", meta.free_blocks()); - otype = OutputType::Integer; + output_type = OutputType::Integer; } // file system ID in hex 'i' => { arg = format!("{:x}", meta.fsid()); - otype = OutputType::UnsignedHex; + output_type = OutputType::UnsignedHex; } // maximum length of filenames 'l' => { arg = format!("{}", meta.namelen()); - otype = OutputType::Unsigned; + output_type = OutputType::Unsigned; } // file name 'n' => { arg = file.to_owned(); - otype = OutputType::Str; + output_type = OutputType::Str; } // block size (for faster transfers) 's' => { - arg = format!("{}", meta.iosize()); - otype = OutputType::Unsigned; + arg = format!("{}", meta.io_size()); + output_type = OutputType::Unsigned; } // fundamental block size (for block counts) 'S' => { - arg = format!("{}", meta.blksize()); - otype = OutputType::Unsigned; + arg = format!("{}", meta.block_size()); + output_type = OutputType::Unsigned; } // file system type in hex 't' => { arg = format!("{:x}", meta.fs_type()); - otype = OutputType::UnsignedHex; + output_type = OutputType::UnsignedHex; } // file system type in human readable form 'T' => { arg = pretty_fstype(meta.fs_type()).into_owned(); - otype = OutputType::Str; + output_type = OutputType::Str; } _ => { arg = "?".to_owned(); - otype = OutputType::Unknown; + output_type = OutputType::Unknown; } } - print_it(&arg, otype, flag, width, precision); + print_it(&arg, output_type, flag, width, precision); } } } @@ -850,34 +851,34 @@ impl Stater { 0 } - // taken from coreutils/src/stat.c - fn default_fmt(showfs: bool, terse: bool, dev: bool) -> String { + fn default_format(show_fs: bool, terse: bool, show_dev_type: bool) -> String { // SELinux related format is *ignored* - let mut fmtstr = String::with_capacity(36); - if showfs { + let mut format_str = String::with_capacity(36); + if show_fs { if terse { - fmtstr.push_str("%n %i %l %t %s %S %b %f %a %c %d\n"); + format_str.push_str("%n %i %l %t %s %S %b %f %a %c %d\n"); } else { - fmtstr.push_str( + format_str.push_str( " File: \"%n\"\n ID: %-8i Namelen: %-7l Type: %T\nBlock \ size: %-10s Fundamental block size: %S\nBlocks: Total: %-10b \ Free: %-10f Available: %a\nInodes: Total: %-10c Free: %d\n", ); } } else if terse { - fmtstr.push_str("%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %W %o\n"); + format_str.push_str("%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %W %o\n"); } else { - fmtstr.push_str(" File: %N\n Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"); - if dev { - fmtstr.push_str("Device: %Dh/%dd\tInode: %-10i Links: %-5h Device type: %t,%T\n"); + format_str.push_str(" File: %N\n Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"); + if show_dev_type { + format_str + .push_str("Device: %Dh/%dd\tInode: %-10i Links: %-5h Device type: %t,%T\n"); } else { - fmtstr.push_str("Device: %Dh/%dd\tInode: %-10i Links: %h\n"); + format_str.push_str("Device: %Dh/%dd\tInode: %-10i Links: %h\n"); } - fmtstr.push_str("Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"); - fmtstr.push_str("Access: %x\nModify: %y\nChange: %z\n Birth: %w\n"); + format_str.push_str("Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"); + format_str.push_str("Access: %x\nModify: %y\nChange: %z\n Birth: %w\n"); } - fmtstr + format_str } } diff --git a/src/uu/stdbuf/src/main.rs b/src/uu/stdbuf/src/main.rs index c020a7a07..1989a3b8d 100644 --- a/src/uu/stdbuf/src/main.rs +++ b/src/uu/stdbuf/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_stdbuf); // spell-checker:ignore procs uucore stdbuf +uucore_procs::main!(uu_stdbuf); diff --git a/src/uu/sum/src/main.rs b/src/uu/sum/src/main.rs index 64b0d4254..85f4d0079 100644 --- a/src/uu/sum/src/main.rs +++ b/src/uu/sum/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_sum); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_sum); diff --git a/src/uu/sync/src/main.rs b/src/uu/sync/src/main.rs index 06d85b278..9786fc371 100644 --- a/src/uu/sync/src/main.rs +++ b/src/uu/sync/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_sync); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_sync); diff --git a/src/uu/tac/src/main.rs b/src/uu/tac/src/main.rs index 93d91e2b7..018821c73 100644 --- a/src/uu/tac/src/main.rs +++ b/src/uu/tac/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tac); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_tac); diff --git a/src/uu/tail/README.md b/src/uu/tail/README.md index 53936a609..b7f92f8e4 100644 --- a/src/uu/tail/README.md +++ b/src/uu/tail/README.md @@ -2,17 +2,17 @@ - Rudimentary tail implementation. -## Missing features: +## Missing features ### Flags with features -* [ ] `--max-unchanged-stats` : with `--follow=name`, reopen a FILE which has not changed size after N (default 5) iterations to see if it has been unlinked or renamed (this is the usual case of rotated log files). With inotify, this option is rarely useful. -* [ ] `--retry` : keep trying to open a file even when it is or becomes inaccessible; useful when follow‐ing by name, i.e., with `--follow=name` +- [ ] `--max-unchanged-stats` : with `--follow=name`, reopen a FILE which has not changed size after N (default 5) iterations to see if it has been unlinked or renamed (this is the usual case of rotated log files). With `inotify`, this option is rarely useful. +- [ ] `--retry` : keep trying to open a file even when it is or becomes inaccessible; useful when follow‐ing by name, i.e., with `--follow=name` ### Others - [ ] The current implementation does not handle `-` as an alias for stdin. -## Possible optimizations: +## Possible optimizations -* [ ] Don't read the whole file if not using `-f` and input is regular file. Read in chunks from the end going backwards, reading each individual chunk forward. +- [ ] Don't read the whole file if not using `-f` and input is regular file. Read in chunks from the end going backwards, reading each individual chunk forward. diff --git a/src/uu/tail/src/main.rs b/src/uu/tail/src/main.rs index 52818fad6..dd89ce2c7 100644 --- a/src/uu/tail/src/main.rs +++ b/src/uu/tail/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tail); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_tail); diff --git a/src/uu/tee/src/main.rs b/src/uu/tee/src/main.rs index 1314f353e..2b483d9d8 100644 --- a/src/uu/tee/src/main.rs +++ b/src/uu/tee/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tee); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_tee); diff --git a/src/uu/tee/src/tee.rs b/src/uu/tee/src/tee.rs index c21559b3b..82a06daa2 100644 --- a/src/uu/tee/src/tee.rs +++ b/src/uu/tee/src/tee.rs @@ -119,7 +119,7 @@ fn tee(options: Options) -> Result<()> { // TODO: replaced generic 'copy' call to be able to stop copying // if all outputs are closed (due to errors) - if copy(input, &mut output).is_err() || output.flush().is_err() || output.error_occured() { + if copy(input, &mut output).is_err() || output.flush().is_err() || output.error_occurred() { Err(Error::new(ErrorKind::Other, "")) } else { Ok(()) @@ -155,7 +155,7 @@ impl MultiWriter { writers, } } - fn error_occured(&self) -> bool { + fn error_occurred(&self) -> bool { self.writers.len() != self.initial_len } } diff --git a/src/uu/test/src/main.rs b/src/uu/test/src/main.rs index 5018a5c8c..9f4e6985f 100644 --- a/src/uu/test/src/main.rs +++ b/src/uu/test/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_test); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_test); diff --git a/src/uu/test/src/parser.rs b/src/uu/test/src/parser.rs index a77bfabb3..d4302bd67 100644 --- a/src/uu/test/src/parser.rs +++ b/src/uu/test/src/parser.rs @@ -5,6 +5,8 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. +// spell-checker:ignore (grammar) BOOLOP STRLEN FILETEST FILEOP INTOP STRINGOP ; (vars) LParen StrlenOp + use std::ffi::OsString; use std::iter::Peekable; diff --git a/src/uu/test/src/test.rs b/src/uu/test/src/test.rs index 86950ecc2..acf0f7eca 100644 --- a/src/uu/test/src/test.rs +++ b/src/uu/test/src/test.rs @@ -6,7 +6,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (ToDO) retval paren prec subprec cond +// spell-checker:ignore (vars) FiletestOp StrlenOp mod parser; @@ -122,7 +122,7 @@ fn eval(stack: &mut Vec) -> Result { } } -fn integers(a: &OsStr, b: &OsStr, cond: &OsStr) -> Result { +fn integers(a: &OsStr, b: &OsStr, op: &OsStr) -> Result { let format_err = |value| format!("invalid integer ‘{}’", value); let a = a.to_string_lossy(); @@ -131,15 +131,15 @@ fn integers(a: &OsStr, b: &OsStr, cond: &OsStr) -> Result { let b = b.to_string_lossy(); let b: i64 = b.parse().map_err(|_| format_err(b))?; - let cond = cond.to_string_lossy(); - Ok(match cond.as_ref() { + let operator = op.to_string_lossy(); + Ok(match operator.as_ref() { "-eq" => a == b, "-ne" => a != b, "-gt" => a > b, "-ge" => a >= b, "-lt" => a < b, "-le" => a <= b, - _ => return Err(format!("unknown operator ‘{}’", cond)), + _ => return Err(format!("unknown operator ‘{}’", operator)), }) } @@ -177,7 +177,7 @@ enum PathCondition { } #[cfg(not(windows))] -fn path(path: &OsStr, cond: PathCondition) -> bool { +fn path(path: &OsStr, condition: PathCondition) -> bool { use std::fs::{self, Metadata}; use std::os::unix::fs::{FileTypeExt, MetadataExt}; @@ -208,7 +208,7 @@ fn path(path: &OsStr, cond: PathCondition) -> bool { } }; - let metadata = if cond == PathCondition::SymLink { + let metadata = if condition == PathCondition::SymLink { fs::symlink_metadata(path) } else { fs::metadata(path) @@ -223,7 +223,7 @@ fn path(path: &OsStr, cond: PathCondition) -> bool { let file_type = metadata.file_type(); - match cond { + match condition { PathCondition::BlockSpecial => file_type.is_block_device(), PathCondition::CharacterSpecial => file_type.is_char_device(), PathCondition::Directory => file_type.is_dir(), @@ -242,7 +242,7 @@ fn path(path: &OsStr, cond: PathCondition) -> bool { } #[cfg(windows)] -fn path(path: &OsStr, cond: PathCondition) -> bool { +fn path(path: &OsStr, condition: PathCondition) -> bool { use std::fs::metadata; let stat = match metadata(path) { @@ -250,7 +250,7 @@ fn path(path: &OsStr, cond: PathCondition) -> bool { _ => return false, }; - match cond { + match condition { PathCondition::BlockSpecial => false, PathCondition::CharacterSpecial => false, PathCondition::Directory => stat.is_dir(), diff --git a/src/uu/timeout/src/main.rs b/src/uu/timeout/src/main.rs index 20c4271d9..2479f91c1 100644 --- a/src/uu/timeout/src/main.rs +++ b/src/uu/timeout/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_timeout); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_timeout); diff --git a/src/uu/timeout/src/timeout.rs b/src/uu/timeout/src/timeout.rs index 7d557f1ce..dc8979143 100644 --- a/src/uu/timeout/src/timeout.rs +++ b/src/uu/timeout/src/timeout.rs @@ -159,8 +159,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ) } -/// TODO: Improve exit codes, and make them consistent with the GNU Coreutil -/// exit codes. +/// TODO: Improve exit codes, and make them consistent with the GNU Coreutils exit codes. fn timeout( cmdname: &str, diff --git a/src/uu/touch/src/main.rs b/src/uu/touch/src/main.rs index bad67efd4..e8a2729a2 100644 --- a/src/uu/touch/src/main.rs +++ b/src/uu/touch/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_touch); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_touch); diff --git a/src/uu/tr/src/main.rs b/src/uu/tr/src/main.rs index 8bed990e5..9118c3628 100644 --- a/src/uu/tr/src/main.rs +++ b/src/uu/tr/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tr); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_tr); diff --git a/src/uu/true/src/main.rs b/src/uu/true/src/main.rs index 7e009be8a..b30f4d4cb 100644 --- a/src/uu/true/src/main.rs +++ b/src/uu/true/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_true); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_true); diff --git a/src/uu/truncate/src/main.rs b/src/uu/truncate/src/main.rs index 91fe70b6d..46e65faea 100644 --- a/src/uu/truncate/src/main.rs +++ b/src/uu/truncate/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_truncate); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_truncate); diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index 3a6077b3c..50ab5c45e 100644 --- a/src/uu/truncate/src/truncate.rs +++ b/src/uu/truncate/src/truncate.rs @@ -40,13 +40,13 @@ impl TruncateMode { /// ``` fn to_size(&self, fsize: u64) -> u64 { match self { - TruncateMode::Absolute(modsize) => *modsize, - TruncateMode::Extend(modsize) => fsize + modsize, - TruncateMode::Reduce(modsize) => fsize - modsize, - TruncateMode::AtMost(modsize) => fsize.min(*modsize), - TruncateMode::AtLeast(modsize) => fsize.max(*modsize), - TruncateMode::RoundDown(modsize) => fsize - fsize % modsize, - TruncateMode::RoundUp(modsize) => fsize + fsize % modsize, + TruncateMode::Absolute(size) => *size, + TruncateMode::Extend(size) => fsize + size, + TruncateMode::Reduce(size) => fsize - size, + TruncateMode::AtMost(size) => fsize.min(*size), + TruncateMode::AtLeast(size) => fsize.max(*size), + TruncateMode::RoundDown(size) => fsize - fsize % size, + TruncateMode::RoundUp(size) => fsize + fsize % size, } } } diff --git a/src/uu/tsort/src/main.rs b/src/uu/tsort/src/main.rs index 6b108cc5e..0694678d4 100644 --- a/src/uu/tsort/src/main.rs +++ b/src/uu/tsort/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tsort); // spell-checker:ignore procs uucore tsort +uucore_procs::main!(uu_tsort); diff --git a/src/uu/tty/src/main.rs b/src/uu/tty/src/main.rs index 8cb1cbb4b..01a01e5ca 100644 --- a/src/uu/tty/src/main.rs +++ b/src/uu/tty/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tty); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_tty); diff --git a/src/uu/uname/src/main.rs b/src/uu/uname/src/main.rs index f40104670..5252f4716 100644 --- a/src/uu/uname/src/main.rs +++ b/src/uu/uname/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_uname); // spell-checker:ignore procs uucore uname +uucore_procs::main!(uu_uname); diff --git a/src/uu/unexpand/src/main.rs b/src/uu/unexpand/src/main.rs index 82d11dd95..2e7b1d967 100644 --- a/src/uu/unexpand/src/main.rs +++ b/src/uu/unexpand/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_unexpand); // spell-checker:ignore procs uucore unexpand +uucore_procs::main!(uu_unexpand); diff --git a/src/uu/uniq/src/main.rs b/src/uu/uniq/src/main.rs index dd4b6da1a..361c39f14 100644 --- a/src/uu/uniq/src/main.rs +++ b/src/uu/uniq/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_uniq); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_uniq); diff --git a/src/uu/unlink/src/main.rs b/src/uu/unlink/src/main.rs index f01b6bac3..b03d4a675 100644 --- a/src/uu/unlink/src/main.rs +++ b/src/uu/unlink/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_unlink); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_unlink); diff --git a/src/uu/uptime/src/main.rs b/src/uu/uptime/src/main.rs index 352703eb3..be5d5ab01 100644 --- a/src/uu/uptime/src/main.rs +++ b/src/uu/uptime/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_uptime); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_uptime); diff --git a/src/uu/users/src/main.rs b/src/uu/users/src/main.rs index f065c633c..f30a01ecb 100644 --- a/src/uu/users/src/main.rs +++ b/src/uu/users/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_users); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_users); diff --git a/src/uu/users/src/users.rs b/src/uu/users/src/users.rs index 99e06c1af..664ff55f3 100644 --- a/src/uu/users/src/users.rs +++ b/src/uu/users/src/users.rs @@ -6,6 +6,8 @@ // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. +// spell-checker:ignore (paths) wtmp + #[macro_use] extern crate uucore; diff --git a/src/uu/wc/src/main.rs b/src/uu/wc/src/main.rs index ce5629e51..b58b9cac7 100644 --- a/src/uu/wc/src/main.rs +++ b/src/uu/wc/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_wc); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_wc); diff --git a/src/uu/wc/src/wc.rs b/src/uu/wc/src/wc.rs index 6e95254ee..d990c6679 100644 --- a/src/uu/wc/src/wc.rs +++ b/src/uu/wc/src/wc.rs @@ -5,17 +5,15 @@ // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. -// spell-checker:ignore (ToDO) fpath - #[macro_use] extern crate uucore; mod count_bytes; mod countable; -mod wordcount; +mod word_count; use count_bytes::count_bytes_fast; use countable::WordCountable; -use wordcount::{TitledWordCount, WordCount}; +use word_count::{TitledWordCount, WordCount}; use clap::{App, Arg, ArgMatches}; use thiserror::Error; diff --git a/src/uu/wc/src/wordcount.rs b/src/uu/wc/src/word_count.rs similarity index 98% rename from src/uu/wc/src/wordcount.rs rename to src/uu/wc/src/word_count.rs index 9e2a81fca..bdb510f58 100644 --- a/src/uu/wc/src/wordcount.rs +++ b/src/uu/wc/src/word_count.rs @@ -123,7 +123,7 @@ impl WordCount { /// This struct supplements the actual word count with an optional title that is /// displayed to the user at the end of the program. /// The reason we don't simply include title in the `WordCount` struct is that -/// it would result in unneccesary copying of `String`. +/// it would result in unnecessary copying of `String`. #[derive(Debug, Default, Clone)] pub struct TitledWordCount<'a> { pub title: Option<&'a str>, diff --git a/src/uu/who/src/main.rs b/src/uu/who/src/main.rs index bc0015a80..a093201a1 100644 --- a/src/uu/who/src/main.rs +++ b/src/uu/who/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_who); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_who); diff --git a/src/uu/whoami/src/main.rs b/src/uu/whoami/src/main.rs index 0439923ee..40de26564 100644 --- a/src/uu/whoami/src/main.rs +++ b/src/uu/whoami/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_whoami); // spell-checker:ignore procs uucore whoami +uucore_procs::main!(uu_whoami); diff --git a/src/uu/whoami/src/platform/mod.rs b/src/uu/whoami/src/platform/mod.rs index ab0b856e6..b5064a8d2 100644 --- a/src/uu/whoami/src/platform/mod.rs +++ b/src/uu/whoami/src/platform/mod.rs @@ -10,10 +10,10 @@ // spell-checker:ignore (ToDO) getusername #[cfg(unix)] -pub use self::unix::getusername; +pub use self::unix::get_username; #[cfg(windows)] -pub use self::windows::getusername; +pub use self::windows::get_username; #[cfg(unix)] mod unix; diff --git a/src/uu/whoami/src/platform/unix.rs b/src/uu/whoami/src/platform/unix.rs index 33bfa6025..3d5fc6f54 100644 --- a/src/uu/whoami/src/platform/unix.rs +++ b/src/uu/whoami/src/platform/unix.rs @@ -14,7 +14,7 @@ use std::io::Result; use uucore::entries::uid2usr; use uucore::libc::geteuid; -pub unsafe fn getusername() -> Result { +pub unsafe fn get_username() -> Result { // Get effective user id let uid = geteuid(); uid2usr(uid) diff --git a/src/uu/whoami/src/platform/windows.rs b/src/uu/whoami/src/platform/windows.rs index 1d65281bd..5d648877b 100644 --- a/src/uu/whoami/src/platform/windows.rs +++ b/src/uu/whoami/src/platform/windows.rs @@ -7,8 +7,6 @@ * file that was distributed with this source code. */ -// spell-checker:ignore (ToDO) advapi lmcons winnt getusername WCHAR UNLEN - extern crate winapi; use self::winapi::shared::lmcons; @@ -18,7 +16,7 @@ use std::io::{Error, Result}; use std::mem; use uucore::wide::FromWide; -pub unsafe fn getusername() -> Result { +pub unsafe fn get_username() -> Result { #[allow(deprecated)] let mut buffer: [winnt::WCHAR; lmcons::UNLEN as usize + 1] = mem::uninitialized(); let mut len = buffer.len() as minwindef::DWORD; diff --git a/src/uu/whoami/src/whoami.rs b/src/uu/whoami/src/whoami.rs index 21e170dec..383fb40b5 100644 --- a/src/uu/whoami/src/whoami.rs +++ b/src/uu/whoami/src/whoami.rs @@ -7,8 +7,6 @@ /* last synced with: whoami (GNU coreutils) 8.21 */ -// spell-checker:ignore (ToDO) getusername - #[macro_use] extern crate clap; #[macro_use] @@ -38,7 +36,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { pub fn exec() { unsafe { - match platform::getusername() { + match platform::get_username() { Ok(username) => println!("{}", username), Err(err) => match err.raw_os_error() { Some(0) | None => crash!(1, "failed to get username"), diff --git a/src/uu/yes/src/main.rs b/src/uu/yes/src/main.rs index 597eb5b57..dc5bf6a0c 100644 --- a/src/uu/yes/src/main.rs +++ b/src/uu/yes/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_yes); // spell-checker:ignore procs uucore +uucore_procs::main!(uu_yes); diff --git a/src/uucore/src/lib/features/fs.rs b/src/uucore/src/lib/features/fs.rs index afaa07af1..38cdbef94 100644 --- a/src/uucore/src/lib/features/fs.rs +++ b/src/uucore/src/lib/features/fs.rs @@ -390,8 +390,8 @@ mod tests { test: "C:/you/later", }, NormalizePathTestCase { - path: "\\networkshare/a//foo//./bar", - test: "\\networkshare/a/foo/bar", + path: "\\networkShare/a//foo//./bar", + test: "\\networkShare/a/foo/bar", }, ]; @@ -411,6 +411,7 @@ mod tests { #[cfg(unix)] #[test] fn test_display_permissions() { + // spell-checker:ignore (perms) brwsr drwxr rwxr assert_eq!( "drwxr-xr-x", display_permissions_unix(S_IFDIR | 0o755, true) diff --git a/src/uucore/src/lib/features/fsext.rs b/src/uucore/src/lib/features/fsext.rs index 6343ecd50..d3eec468a 100644 --- a/src/uucore/src/lib/features/fsext.rs +++ b/src/uucore/src/lib/features/fsext.rs @@ -7,7 +7,7 @@ // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. -// spell-checker:ignore (ToDO) strerror IFBLK IFCHR IFDIR IFLNK IFIFO IFMT IFREG IFSOCK subsec nanos gnulib statfs Sstatfs bitrig statvfs iosize blksize fnodes fsid namelen bsize bfree bavail ffree frsize namemax errno fstype adfs acfs aufs affs autofs befs bdevfs binfmt ceph cgroups cifs configfs cramfs cgroupfs debugfs devfs devpts ecryptfs btrfs efivarfs exofs fhgfs fuseblk fusectl futexfs gpfs hfsx hostfs hpfs inodefs ibrix inotifyfs isofs jffs logfs hugetlbfs mqueue nsfs ntfs ocfs panfs pipefs ramfs romfs nfsd nilfs pstorefs reiserfs securityfs smackfs snfs sockfs squashfs sysfs sysv tempfs tracefs ubifs usbdevfs vmhgfs tmpfs vxfs wslfs xenfs vzfs openprom overlayfs +// spell-checker:ignore (arch) bitrig ; (fs) cifs smbfs extern crate time; @@ -88,7 +88,7 @@ use std::time::UNIX_EPOCH; target_os = "android", target_os = "freebsd" ))] -pub use libc::statfs as Sstatfs; +pub use libc::statfs as StatFs; #[cfg(any( target_os = "openbsd", target_os = "netbsd", @@ -96,7 +96,7 @@ pub use libc::statfs as Sstatfs; target_os = "bitrig", target_os = "dragonfly" ))] -pub use libc::statvfs as Sstatfs; +pub use libc::statvfs as StatFs; #[cfg(any( target_os = "linux", @@ -168,6 +168,7 @@ impl MountInfo { } } // set MountInfo::dummy + // spell-checker:disable match self.fs_type.as_ref() { "autofs" | "proc" | "subfs" /* for Linux 2.6/3.x */ @@ -181,6 +182,7 @@ impl MountInfo { _ => self.dummy = self.fs_type == "none" && !self.mount_option.contains(MOUNT_OPT_BIND) } + // spell-checker:enable // set MountInfo::remote #[cfg(windows)] { @@ -203,6 +205,7 @@ impl MountInfo { #[cfg(target_os = "linux")] fn new(file_name: &str, raw: Vec<&str>) -> Option { match file_name { + // spell-checker:ignore (word) noatime // Format: 36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue // "man proc" for more details LINUX_MOUNTINFO => { @@ -307,21 +310,24 @@ impl MountInfo { #[cfg(any(target_vendor = "apple", target_os = "freebsd"))] use std::ffi::CStr; #[cfg(any(target_os = "freebsd", target_vendor = "apple"))] -impl From for MountInfo { - fn from(statfs: Sstatfs) -> Self { +impl From for MountInfo { + fn from(statfs: StatFs) -> Self { let mut info = MountInfo { dev_id: "".to_string(), dev_name: unsafe { + // spell-checker:disable-next-line CStr::from_ptr(&statfs.f_mntfromname[0]) .to_string_lossy() .into_owned() }, fs_type: unsafe { + // spell-checker:disable-next-line CStr::from_ptr(&statfs.f_fstypename[0]) .to_string_lossy() .into_owned() }, mount_dir: unsafe { + // spell-checker:disable-next-line CStr::from_ptr(&statfs.f_mntonname[0]) .to_string_lossy() .into_owned() @@ -341,14 +347,15 @@ use libc::c_int; #[cfg(any(target_os = "freebsd", target_vendor = "apple"))] extern "C" { #[cfg(all(target_vendor = "apple", target_arch = "x86_64"))] - #[link_name = "getmntinfo$INODE64"] - fn getmntinfo(mntbufp: *mut *mut Sstatfs, flags: c_int) -> c_int; + #[link_name = "getmntinfo$INODE64"] // spell-checker:disable-line + fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int; #[cfg(any( all(target_os = "freebsd"), all(target_vendor = "apple", target_arch = "aarch64") ))] - fn getmntinfo(mntbufp: *mut *mut Sstatfs, flags: c_int) -> c_int; + #[link_name = "getmntinfo"] // spell-checker:disable-line + fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int; } #[cfg(target_os = "linux")] @@ -363,11 +370,11 @@ use std::slice; pub fn read_fs_list() -> Vec { #[cfg(target_os = "linux")] { - let (file_name, fobj) = File::open(LINUX_MOUNTINFO) + let (file_name, f) = File::open(LINUX_MOUNTINFO) .map(|f| (LINUX_MOUNTINFO, f)) .or_else(|_| File::open(LINUX_MTAB).map(|f| (LINUX_MTAB, f))) .expect("failed to find mount list files"); - let reader = BufReader::new(fobj); + let reader = BufReader::new(f); reader .lines() .filter_map(|line| line.ok()) @@ -379,12 +386,12 @@ pub fn read_fs_list() -> Vec { } #[cfg(any(target_os = "freebsd", target_vendor = "apple"))] { - let mut mptr: *mut Sstatfs = ptr::null_mut(); - let len = unsafe { getmntinfo(&mut mptr, 1_i32) }; + let mut mount_buffer_ptr: *mut StatFs = ptr::null_mut(); + let len = unsafe { get_mount_info(&mut mount_buffer_ptr, 1_i32) }; if len < 0 { - crash!(1, "getmntinfo failed"); + crash!(1, "get_mount_info() failed"); } - let mounts = unsafe { slice::from_raw_parts(mptr, len as usize) }; + let mounts = unsafe { slice::from_raw_parts(mount_buffer_ptr, len as usize) }; mounts .iter() .map(|m| MountInfo::from(*m)) @@ -446,7 +453,7 @@ pub struct FsUsage { impl FsUsage { #[cfg(unix)] - pub fn new(statvfs: Sstatfs) -> FsUsage { + pub fn new(statvfs: StatFs) -> FsUsage { { FsUsage { blocksize: statvfs.f_bsize as u64, // or `statvfs.f_frsize` ? @@ -523,20 +530,20 @@ impl FsUsage { #[cfg(unix)] pub trait FsMeta { fn fs_type(&self) -> i64; - fn iosize(&self) -> u64; - fn blksize(&self) -> i64; + fn io_size(&self) -> u64; + fn block_size(&self) -> i64; fn total_blocks(&self) -> u64; fn free_blocks(&self) -> u64; fn avail_blocks(&self) -> u64; - fn total_fnodes(&self) -> u64; - fn free_fnodes(&self) -> u64; + fn total_file_nodes(&self) -> u64; + fn free_file_nodes(&self) -> u64; fn fsid(&self) -> u64; fn namelen(&self) -> u64; } #[cfg(unix)] -impl FsMeta for Sstatfs { - fn blksize(&self) -> i64 { +impl FsMeta for StatFs { + fn block_size(&self) -> i64 { self.f_bsize as i64 } fn total_blocks(&self) -> u64 { @@ -548,10 +555,10 @@ impl FsMeta for Sstatfs { fn avail_blocks(&self) -> u64 { self.f_bavail as u64 } - fn total_fnodes(&self) -> u64 { + fn total_file_nodes(&self) -> u64 { self.f_files as u64 } - fn free_fnodes(&self) -> u64 { + fn free_file_nodes(&self) -> u64 { self.f_ffree as u64 } #[cfg(any(target_os = "linux", target_vendor = "apple", target_os = "freebsd"))] @@ -565,16 +572,16 @@ impl FsMeta for Sstatfs { } #[cfg(target_os = "linux")] - fn iosize(&self) -> u64 { + fn io_size(&self) -> u64 { self.f_frsize as u64 } #[cfg(any(target_vendor = "apple", target_os = "freebsd"))] - fn iosize(&self) -> u64 { + fn io_size(&self) -> u64 { self.f_iosize as u64 } // XXX: dunno if this is right #[cfg(not(any(target_vendor = "apple", target_os = "freebsd", target_os = "linux")))] - fn iosize(&self) -> u64 { + fn io_size(&self) -> u64 { self.f_bsize as u64 } @@ -605,23 +612,23 @@ impl FsMeta for Sstatfs { } #[cfg(target_os = "freebsd")] fn namelen(&self) -> u64 { - self.f_namemax as u64 + self.f_namemax as u64 // spell-checker:disable-line } // XXX: should everything just use statvfs? #[cfg(not(any(target_vendor = "apple", target_os = "freebsd", target_os = "linux")))] fn namelen(&self) -> u64 { - self.f_namemax as u64 + self.f_namemax as u64 // spell-checker:disable-line } } #[cfg(unix)] -pub fn statfs>(path: P) -> Result +pub fn statfs>(path: P) -> Result where Vec: From

, { match CString::new(path) { Ok(p) => { - let mut buffer: Sstatfs = unsafe { mem::zeroed() }; + let mut buffer: StatFs = unsafe { mem::zeroed() }; unsafe { match statfs_fn(p.as_ptr(), &mut buffer) { 0 => Ok(buffer), @@ -667,12 +674,13 @@ pub fn pretty_filetype<'a>(mode: mode_t, size: u64) -> &'a str { S_IFIFO => "fifo", S_IFSOCK => "socket", // TODO: Other file types - // See coreutils/gnulib/lib/file-type.c + // See coreutils/gnulib/lib/file-type.c // spell-checker:disable-line _ => "weird file", } } pub fn pretty_fstype<'a>(fstype: i64) -> Cow<'a, str> { + // spell-checker:disable match fstype { 0x6163_6673 => "acfs".into(), 0xADF5 => "adfs".into(), @@ -790,6 +798,7 @@ pub fn pretty_fstype<'a>(fstype: i64) -> Cow<'a, str> { 0x2FC1_2FC1 => "zfs".into(), other => format!("UNKNOWN ({:#x})", other).into(), } + // spell-checker:enable } #[cfg(test)] @@ -808,6 +817,7 @@ mod tests { #[test] fn test_fs_type() { + // spell-checker:disable assert_eq!("ext2/ext3", pretty_fstype(0xEF53)); assert_eq!("tmpfs", pretty_fstype(0x01021994)); assert_eq!("nfs", pretty_fstype(0x6969)); @@ -817,5 +827,6 @@ mod tests { assert_eq!("ntfs", pretty_fstype(0x5346544e)); assert_eq!("fat", pretty_fstype(0x4006)); assert_eq!("UNKNOWN (0x1234)", pretty_fstype(0x1234)); + // spell-checker:enable } } diff --git a/src/uucore/src/lib/features/perms.rs b/src/uucore/src/lib/features/perms.rs index 36f56206d..eb6cca102 100644 --- a/src/uucore/src/lib/features/perms.rs +++ b/src/uucore/src/lib/features/perms.rs @@ -26,14 +26,14 @@ pub enum Verbosity { } /// Actually perform the change of group on a path -fn chgrp>(path: P, dgid: gid_t, follow: bool) -> IOResult<()> { +fn chgrp>(path: P, gid: gid_t, follow: bool) -> IOResult<()> { let path = path.as_ref(); let s = CString::new(path.as_os_str().as_bytes()).unwrap(); let ret = unsafe { if follow { - libc::chown(s.as_ptr(), 0_u32.wrapping_sub(1), dgid) + libc::chown(s.as_ptr(), 0_u32.wrapping_sub(1), gid) } else { - lchown(s.as_ptr(), 0_u32.wrapping_sub(1), dgid) + lchown(s.as_ptr(), 0_u32.wrapping_sub(1), gid) } }; if ret == 0 { @@ -100,14 +100,14 @@ pub fn wrap_chgrp>( } /// Actually perform the change of owner on a path -fn chown>(path: P, duid: uid_t, dgid: gid_t, follow: bool) -> IOResult<()> { +fn chown>(path: P, uid: uid_t, gid: gid_t, follow: bool) -> IOResult<()> { let path = path.as_ref(); let s = CString::new(path.as_os_str().as_bytes()).unwrap(); let ret = unsafe { if follow { - libc::chown(s.as_ptr(), duid, dgid) + libc::chown(s.as_ptr(), uid, gid) } else { - lchown(s.as_ptr(), duid, dgid) + lchown(s.as_ptr(), uid, gid) } }; if ret == 0 { diff --git a/src/uucore/src/lib/features/ringbuffer.rs b/src/uucore/src/lib/features/ringbuffer.rs index 60847df8f..1cb0d2b0d 100644 --- a/src/uucore/src/lib/features/ringbuffer.rs +++ b/src/uucore/src/lib/features/ringbuffer.rs @@ -47,11 +47,11 @@ impl RingBuffer { } pub fn from_iter(iter: impl Iterator, size: usize) -> RingBuffer { - let mut ringbuf = RingBuffer::new(size); + let mut ring_buffer = RingBuffer::new(size); for value in iter { - ringbuf.push_back(value); + ring_buffer.push_back(value); } - ringbuf + ring_buffer } /// Append a value to the end of the ring buffer. diff --git a/src/uucore/src/lib/features/utmpx.rs b/src/uucore/src/lib/features/utmpx.rs index 826831ba6..a794b01da 100644 --- a/src/uucore/src/lib/features/utmpx.rs +++ b/src/uucore/src/lib/features/utmpx.rs @@ -238,8 +238,8 @@ impl UtmpxIter { /// If not set, default record file will be used(file path depends on the target OS) pub fn read_from(self, f: &str) -> Self { let res = unsafe { - let cstr = CString::new(f).unwrap(); - utmpxname(cstr.as_ptr()) + let cstring = CString::new(f).unwrap(); + utmpxname(cstring.as_ptr()) }; if res != 0 { show_warning!("utmpxname: {}", IOError::last_os_error()); diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index e7f29e20c..0b0d0fddf 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -130,7 +130,7 @@ pub trait Args: Iterator + Sized { full_conversion = false; let lossy_conversion = s_ret.to_string_lossy(); eprintln!( - "Input with broken encoding occured! (s = '{}') ", + "Input with broken encoding occurred! (s = '{}') ", &lossy_conversion ); match handling { @@ -159,7 +159,7 @@ pub trait Args: Iterator + Sized { } } - /// convience function for a more slim interface + /// convenience function for a more slim interface fn collect_str_lossy(self) -> ConversionResult { self.collect_str(InvalidEncodingHandling::ConvertLossy) } diff --git a/src/uucore/src/lib/macros.rs b/src/uucore/src/lib/macros.rs index 438fec960..07d47eed8 100644 --- a/src/uucore/src/lib/macros.rs +++ b/src/uucore/src/lib/macros.rs @@ -21,7 +21,7 @@ macro_rules! executable( }) ); -/// Show an error to stderr in a silimar style to GNU coreutils. +/// Show an error to stderr in a similar style to GNU coreutils. #[macro_export] macro_rules! show_error( ($($args:tt)+) => ({ @@ -30,7 +30,7 @@ macro_rules! show_error( }) ); -/// Show a warning to stderr in a silimar style to GNU coreutils. +/// Show a warning to stderr in a similar style to GNU coreutils. #[macro_export] macro_rules! show_error_custom_description ( ($err:expr,$($args:tt)+) => ({ @@ -47,7 +47,7 @@ macro_rules! show_warning( }) ); -/// Show a bad inocation help message in a similar style to GNU coreutils. +/// Show a bad invocation help message in a similar style to GNU coreutils. #[macro_export] macro_rules! show_usage_error( ($($args:tt)+) => ({ diff --git a/src/uucore/src/lib/mods/os.rs b/src/uucore/src/lib/mods/os.rs index da2002161..dd06f4739 100644 --- a/src/uucore/src/lib/mods/os.rs +++ b/src/uucore/src/lib/mods/os.rs @@ -1,5 +1,8 @@ /// Test if the program is running under WSL // ref: @@ + +// spell-checker:ignore (path) osrelease + pub fn is_wsl_1() -> bool { #[cfg(target_os = "linux")] { diff --git a/tests/benches/factor/benches/gcd.rs b/tests/benches/factor/benches/gcd.rs index 803c37d3c..f2bae51c7 100644 --- a/tests/benches/factor/benches/gcd.rs +++ b/tests/benches/factor/benches/gcd.rs @@ -3,7 +3,7 @@ use uu_factor::numeric; fn gcd(c: &mut Criterion) { let inputs = { - // Deterministic RNG; use an explicitely-named RNG to guarantee stability + // Deterministic RNG; use an explicitly-named RNG to guarantee stability use rand::{RngCore, SeedableRng}; use rand_chacha::ChaCha8Rng; const SEED: u64 = 0xa_b4d_1dea_dead_cafe; diff --git a/tests/benches/factor/benches/table.rs b/tests/benches/factor/benches/table.rs index 0b31b2b4c..9090c7d51 100644 --- a/tests/benches/factor/benches/table.rs +++ b/tests/benches/factor/benches/table.rs @@ -15,10 +15,10 @@ fn table(c: &mut Criterion) { CHUNK_SIZE ); let inputs = { - // Deterministic RNG; use an explicitely-named RNG to guarantee stability + // Deterministic RNG; use an explicitly-named RNG to guarantee stability use rand::{RngCore, SeedableRng}; use rand_chacha::ChaCha8Rng; - const SEED: u64 = 0xdead_bebe_ea75_cafe; + const SEED: u64 = 0xdead_bebe_ea75_cafe; // spell-checker:disable-line let mut rng = ChaCha8Rng::seed_from_u64(SEED); std::iter::repeat_with(move || array_init::<_, _, INPUT_SIZE>(|_| rng.next_u64())) diff --git a/tests/by-util/test_base32.rs b/tests/by-util/test_base32.rs index 788b85efa..8e3e780c5 100644 --- a/tests/by-util/test_base32.rs +++ b/tests/by-util/test_base32.rs @@ -14,14 +14,14 @@ fn test_encode() { new_ucmd!() .pipe_in(input) .succeeds() - .stdout_only("JBSWY3DPFQQFO33SNRSCC===\n"); + .stdout_only("JBSWY3DPFQQFO33SNRSCC===\n"); // spell-checker:disable-line // Using '-' as our file new_ucmd!() .arg("-") .pipe_in(input) .succeeds() - .stdout_only("JBSWY3DPFQQFO33SNRSCC===\n"); + .stdout_only("JBSWY3DPFQQFO33SNRSCC===\n"); // spell-checker:disable-line } #[test] @@ -29,13 +29,13 @@ fn test_base32_encode_file() { new_ucmd!() .arg("input-simple.txt") .succeeds() - .stdout_only("JBSWY3DPFQQFO33SNRSCCCQ=\n"); + .stdout_only("JBSWY3DPFQQFO33SNRSCCCQ=\n"); // spell-checker:disable-line } #[test] fn test_decode() { for decode_param in &["-d", "--decode"] { - let input = "JBSWY3DPFQQFO33SNRSCC===\n"; + let input = "JBSWY3DPFQQFO33SNRSCC===\n"; // spell-checker:disable-line new_ucmd!() .arg(decode_param) .pipe_in(input) @@ -46,7 +46,7 @@ fn test_decode() { #[test] fn test_garbage() { - let input = "aGVsbG8sIHdvcmxkIQ==\0"; + let input = "aGVsbG8sIHdvcmxkIQ==\0"; // spell-checker:disable-line new_ucmd!() .arg("-d") .pipe_in(input) @@ -57,7 +57,7 @@ fn test_garbage() { #[test] fn test_ignore_garbage() { for ignore_garbage_param in &["-i", "--ignore-garbage"] { - let input = "JBSWY\x013DPFQ\x02QFO33SNRSCC===\n"; + let input = "JBSWY\x013DPFQ\x02QFO33SNRSCC===\n"; // spell-checker:disable-line new_ucmd!() .arg("-d") .arg(ignore_garbage_param) @@ -77,7 +77,7 @@ fn test_wrap() { .pipe_in(input) .succeeds() .stdout_only( - "KRUGKIDROVUWG2ZAMJZG\n653OEBTG66BANJ2W24DT\nEBXXMZLSEB2GQZJANRQX\nU6JAMRXWOLQ=\n", + "KRUGKIDROVUWG2ZAMJZG\n653OEBTG66BANJ2W24DT\nEBXXMZLSEB2GQZJANRQX\nU6JAMRXWOLQ=\n", // spell-checker:disable-line ); } } diff --git a/tests/by-util/test_base64.rs b/tests/by-util/test_base64.rs index 75445c933..236f53fb1 100644 --- a/tests/by-util/test_base64.rs +++ b/tests/by-util/test_base64.rs @@ -6,14 +6,14 @@ fn test_encode() { new_ucmd!() .pipe_in(input) .succeeds() - .stdout_only("aGVsbG8sIHdvcmxkIQ==\n"); + .stdout_only("aGVsbG8sIHdvcmxkIQ==\n"); // spell-checker:disable-line // Using '-' as our file new_ucmd!() .arg("-") .pipe_in(input) .succeeds() - .stdout_only("aGVsbG8sIHdvcmxkIQ==\n"); + .stdout_only("aGVsbG8sIHdvcmxkIQ==\n"); // spell-checker:disable-line } #[test] @@ -21,13 +21,13 @@ fn test_base64_encode_file() { new_ucmd!() .arg("input-simple.txt") .succeeds() - .stdout_only("SGVsbG8sIFdvcmxkIQo=\n"); + .stdout_only("SGVsbG8sIFdvcmxkIQo=\n"); // spell-checker:disable-line } #[test] fn test_decode() { for decode_param in &["-d", "--decode"] { - let input = "aGVsbG8sIHdvcmxkIQ=="; + let input = "aGVsbG8sIHdvcmxkIQ=="; // spell-checker:disable-line new_ucmd!() .arg(decode_param) .pipe_in(input) @@ -38,7 +38,7 @@ fn test_decode() { #[test] fn test_garbage() { - let input = "aGVsbG8sIHdvcmxkIQ==\0"; + let input = "aGVsbG8sIHdvcmxkIQ==\0"; // spell-checker:disable-line new_ucmd!() .arg("-d") .pipe_in(input) @@ -49,7 +49,7 @@ fn test_garbage() { #[test] fn test_ignore_garbage() { for ignore_garbage_param in &["-i", "--ignore-garbage"] { - let input = "aGVsbG8sIHdvcmxkIQ==\0"; + let input = "aGVsbG8sIHdvcmxkIQ==\0"; // spell-checker:disable-line new_ucmd!() .arg("-d") .arg(ignore_garbage_param) @@ -68,6 +68,7 @@ fn test_wrap() { .arg("20") .pipe_in(input) .succeeds() + // spell-checker:disable-next-line .stdout_only("VGhlIHF1aWNrIGJyb3du\nIGZveCBqdW1wcyBvdmVy\nIHRoZSBsYXp5IGRvZy4=\n"); } } diff --git a/tests/by-util/test_basename.rs b/tests/by-util/test_basename.rs index 50d22b2eb..d9632106e 100644 --- a/tests/by-util/test_basename.rs +++ b/tests/by-util/test_basename.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) reallylongexecutable + use crate::common::util::*; #[cfg(any(unix, target_os = "redox"))] use std::ffi::OsStr; @@ -50,7 +52,7 @@ fn test_remove_suffix() { } #[test] -fn test_dont_remove_suffix() { +fn test_do_not_remove_suffix() { new_ucmd!() .args(&["/foo/bar/baz", "baz"]) .succeeds() @@ -64,7 +66,7 @@ fn test_multiple_param() { new_ucmd!() .args(&[multiple_param, path, path]) .succeeds() - .stdout_only("baz\nbaz\n"); + .stdout_only("baz\nbaz\n"); // spell-checker:disable-line } } @@ -75,7 +77,7 @@ fn test_suffix_param() { new_ucmd!() .args(&[suffix_param, ".exe", path, path]) .succeeds() - .stdout_only("baz\nbaz\n"); + .stdout_only("baz\nbaz\n"); // spell-checker:disable-line } } diff --git a/tests/by-util/test_cat.rs b/tests/by-util/test_cat.rs index 8ea5bbaae..fadf378ab 100644 --- a/tests/by-util/test_cat.rs +++ b/tests/by-util/test_cat.rs @@ -9,11 +9,12 @@ fn test_output_simple() { new_ucmd!() .args(&["alpha.txt"]) .succeeds() - .stdout_only("abcde\nfghij\nklmno\npqrst\nuvwxyz\n"); + .stdout_only("abcde\nfghij\nklmno\npqrst\nuvwxyz\n"); // spell-checker:disable-line } #[test] fn test_no_options() { + // spell-checker:disable-next-line for fixture in &["empty.txt", "alpha.txt", "nonewline.txt"] { // Give fixture through command line file argument new_ucmd!() @@ -66,8 +67,8 @@ fn test_fifo_symlink() { assert!(s.fixtures.is_fifo("dir/pipe")); // Make cat read the pipe through a symlink - s.fixtures.symlink_file("dir/pipe", "sympipe"); - let proc = s.ucmd().args(&["sympipe"]).run_no_wait(); + s.fixtures.symlink_file("dir/pipe", "sympipe"); // spell-checker:disable-line + let proc = s.ucmd().args(&["sympipe"]).run_no_wait(); // spell-checker:disable-line let data = vec_of_size(128 * 1024); let data2 = data.clone(); @@ -110,7 +111,7 @@ fn test_piped_to_regular_file() { .succeeds(); } let contents = read_to_string(&file_path).unwrap(); - assert_eq!(contents, "abcde\nfghij\nklmno\npqrst\nuvwxyz\n"); + assert_eq!(contents, "abcde\nfghij\nklmno\npqrst\nuvwxyz\n"); // spell-checker:disable-line } } @@ -169,6 +170,7 @@ fn test_directory() { fn test_directory_and_file() { let s = TestScenario::new(util_name!()); s.fixtures.mkdir("test_directory2"); + // spell-checker:disable-next-line for fixture in &["empty.txt", "alpha.txt", "nonewline.txt"] { s.ucmd() .args(&["test_directory2", fixture]) @@ -190,8 +192,8 @@ fn test_three_directories_and_file_and_stdin() { "test_directory3/test_directory4", "alpha.txt", "-", - "filewhichdoesnotexist.txt", - "nonewline.txt", + "file_which_does_not_exist.txt", + "nonewline.txt", // spell-checker:disable-line "test_directory3/test_directory5", "test_directory3/../test_directory3/test_directory5", "test_directory3", @@ -200,12 +202,13 @@ fn test_three_directories_and_file_and_stdin() { .fails() .stderr_is_fixture("three_directories_and_file_and_stdin.stderr.expected") .stdout_is( - "abcde\nfghij\nklmno\npqrst\nuvwxyz\nstdout bytestext without a trailing newline", + "abcde\nfghij\nklmno\npqrst\nuvwxyz\nstdout bytestext without a trailing newline", // spell-checker:disable-line ); } #[test] fn test_output_multi_files_print_all_chars() { + // spell-checker:disable new_ucmd!() .args(&["alpha.txt", "256.txt", "-A", "-n"]) .succeeds() @@ -222,10 +225,12 @@ fn test_output_multi_files_print_all_chars() { M-VM-WM-XM-YM-ZM-[M-\\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-\ pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?", ); + // spell-checker:enable } #[test] fn test_numbered_lines_no_trailing_newline() { + // spell-checker:disable new_ucmd!() .args(&["nonewline.txt", "alpha.txt", "-n"]) .succeeds() @@ -233,6 +238,7 @@ fn test_numbered_lines_no_trailing_newline() { " 1\ttext without a trailing newlineabcde\n 2\tfghij\n \ 3\tklmno\n 4\tpqrst\n 5\tuvwxyz\n", ); + // spell-checker:enable } #[test] @@ -310,6 +316,7 @@ fn test_stdin_squeeze_blank() { #[test] fn test_stdin_number_non_blank() { + // spell-checker:disable-next-line for same_param in &["-b", "--number-nonblank"] { new_ucmd!() .arg(same_param) @@ -322,6 +329,7 @@ fn test_stdin_number_non_blank() { #[test] fn test_non_blank_overrides_number() { + // spell-checker:disable-next-line for &same_param in &["-b", "--number-nonblank"] { new_ucmd!() .args(&[same_param, "-"]) diff --git a/tests/by-util/test_chgrp.rs b/tests/by-util/test_chgrp.rs index c0fc503ae..45380b80b 100644 --- a/tests/by-util/test_chgrp.rs +++ b/tests/by-util/test_chgrp.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) nosuchgroup + use crate::common::util::*; use rust_users::*; diff --git a/tests/by-util/test_chmod.rs b/tests/by-util/test_chmod.rs index 4611d1b96..186c645e5 100644 --- a/tests/by-util/test_chmod.rs +++ b/tests/by-util/test_chmod.rs @@ -21,7 +21,7 @@ struct TestCase { after: u32, } -fn mkfile(file: &str, mode: u32) { +fn make_file(file: &str, mode: u32) { OpenOptions::new() .mode(mode) .create(true) @@ -34,7 +34,7 @@ fn mkfile(file: &str, mode: u32) { } fn run_single_test(test: &TestCase, at: AtPath, mut ucmd: UCommand) { - mkfile(&at.plus_as_string(TEST_FILE), test.before); + make_file(&at.plus_as_string(TEST_FILE), test.before); let perms = at.metadata(TEST_FILE).permissions().mode(); if perms != test.before { panic!( @@ -123,6 +123,7 @@ fn test_chmod_octal() { #[test] #[allow(clippy::unreadable_literal)] +// spell-checker:disable-next-line fn test_chmod_ugoa() { let _guard = UMASK_MUTEX.lock(); @@ -283,7 +284,7 @@ fn test_chmod_reference_file() { }, ]; let (at, ucmd) = at_and_ucmd!(); - mkfile(&at.plus_as_string(REFERENCE_FILE), REFERENCE_PERMS); + make_file(&at.plus_as_string(REFERENCE_FILE), REFERENCE_PERMS); run_single_test(&tests[0], at, ucmd); } @@ -318,10 +319,10 @@ fn test_chmod_recursive() { at.mkdir("a/b"); at.mkdir("a/b/c"); at.mkdir("z"); - mkfile(&at.plus_as_string("a/a"), 0o100444); - mkfile(&at.plus_as_string("a/b/b"), 0o100444); - mkfile(&at.plus_as_string("a/b/c/c"), 0o100444); - mkfile(&at.plus_as_string("z/y"), 0o100444); + make_file(&at.plus_as_string("a/a"), 0o100444); + make_file(&at.plus_as_string("a/b/b"), 0o100444); + make_file(&at.plus_as_string("a/b/c/c"), 0o100444); + make_file(&at.plus_as_string("z/y"), 0o100444); ucmd.arg("-R") .arg("--verbose") @@ -351,9 +352,9 @@ fn test_chmod_non_existing_file() { .arg("-R") .arg("--verbose") .arg("-r,a+w") - .arg("dont-exist") + .arg("does-not-exist") .fails() - .stderr_contains(&"cannot access 'dont-exist': No such file or directory"); + .stderr_contains(&"cannot access 'does-not-exist': No such file or directory"); } #[test] @@ -432,6 +433,7 @@ fn test_chmod_symlink_non_existing_file_recursive() { .no_stdout(); let expected_stdout = &format!( + // spell-checker:disable-next-line "mode of '{}' retained as 0755 (rwxr-xr-x)\nneither symbolic link '{}/{}' nor referent has been changed", test_directory, test_directory, test_symlink ); @@ -473,8 +475,8 @@ fn test_chmod_strip_minus_from_mode() { ("chmod -c -R +w FILE ", "chmod -c -R +w FILE "), ("chmod a=r,=xX FILE", "chmod a=r,=xX FILE"), ( - "chmod -v --reference RFILE -R FILE", - "chmod -v --reference RFILE -R FILE", + "chmod -v --reference REF_FILE -R FILE", + "chmod -v --reference REF_FILE -R FILE", ), ("chmod -Rvc -w-x FILE", "chmod -Rvc w-x FILE"), ("chmod 755 -v FILE", "chmod 755 -v FILE"), diff --git a/tests/by-util/test_chown.rs b/tests/by-util/test_chown.rs index a531fc7f3..c8a8ea538 100644 --- a/tests/by-util/test_chown.rs +++ b/tests/by-util/test_chown.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) agroupthatdoesntexist auserthatdoesntexist groupname notexisting passgrp + use crate::common::util::*; #[cfg(target_os = "linux")] use rust_users::get_effective_uid; diff --git a/tests/by-util/test_chroot.rs b/tests/by-util/test_chroot.rs index 0479e7c3a..3bac07d44 100644 --- a/tests/by-util/test_chroot.rs +++ b/tests/by-util/test_chroot.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) araba newroot userspec + use crate::common::util::*; #[test] diff --git a/tests/by-util/test_cksum.rs b/tests/by-util/test_cksum.rs index 0fd028781..9590c1ac5 100644 --- a/tests/by-util/test_cksum.rs +++ b/tests/by-util/test_cksum.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) asdf + use crate::common::util::*; #[test] @@ -40,7 +42,7 @@ fn test_empty() { #[test] fn test_arg_overrides_stdin() { let (at, mut ucmd) = at_and_ucmd!(); - let input = "foobarfoobar"; + let input = "foobarfoobar"; // spell-checker:disable-line at.touch("a"); @@ -78,17 +80,17 @@ fn test_invalid_file() { } // Make sure crc is correct for files larger than 32 bytes -// but <128 bytes (1 fold pclmul) +// but <128 bytes (1 fold pclmul) // spell-checker:disable-line #[test] fn test_crc_for_bigger_than_32_bytes() { let (_, mut ucmd) = at_and_ucmd!(); let result = ucmd.arg("chars.txt").succeeds(); - let mut stdout_splitted = result.stdout_str().split(' '); + let mut stdout_split = result.stdout_str().split(' '); - let cksum: i64 = stdout_splitted.next().unwrap().parse().unwrap(); - let bytes_cnt: i64 = stdout_splitted.next().unwrap().parse().unwrap(); + let cksum: i64 = stdout_split.next().unwrap().parse().unwrap(); + let bytes_cnt: i64 = stdout_split.next().unwrap().parse().unwrap(); assert_eq!(cksum, 586_047_089); assert_eq!(bytes_cnt, 16); @@ -100,10 +102,10 @@ fn test_stdin_larger_than_128_bytes() { let result = ucmd.arg("larger_than_2056_bytes.txt").succeeds(); - let mut stdout_splitted = result.stdout_str().split(' '); + let mut stdout_split = result.stdout_str().split(' '); - let cksum: i64 = stdout_splitted.next().unwrap().parse().unwrap(); - let bytes_cnt: i64 = stdout_splitted.next().unwrap().parse().unwrap(); + let cksum: i64 = stdout_split.next().unwrap().parse().unwrap(); + let bytes_cnt: i64 = stdout_split.next().unwrap().parse().unwrap(); assert_eq!(cksum, 945_881_979); assert_eq!(bytes_cnt, 2058); diff --git a/tests/by-util/test_comm.rs b/tests/by-util/test_comm.rs index fa8c8beca..01cdcc985 100644 --- a/tests/by-util/test_comm.rs +++ b/tests/by-util/test_comm.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) defaultcheck nocheck + use crate::common::util::*; #[test] @@ -33,19 +35,19 @@ fn ab_dash_three() { } #[test] -fn aempty() { +fn a_empty() { new_ucmd!() .args(&["a", "empty"]) .succeeds() - .stdout_only_fixture("aempty.expected"); + .stdout_only_fixture("aempty.expected"); // spell-checker:disable-line } #[test] -fn emptyempty() { +fn empty_empty() { new_ucmd!() .args(&["empty", "empty"]) .succeeds() - .stdout_only_fixture("emptyempty.expected"); + .stdout_only_fixture("emptyempty.expected"); // spell-checker:disable-line } #[cfg_attr(not(feature = "test_unimplemented"), ignore)] @@ -68,8 +70,8 @@ fn output_delimiter_require_arg() { // even though (info) documentation suggests this is an option // in latest GNU Coreutils comm, it actually is not. -// this test is essentially an alarm in case someone well-intendingly -// implements it. +// this test is essentially an alarm in case some well-intending +// developer implements it. //marked as unimplemented as error message not set yet. #[cfg_attr(not(feature = "test_unimplemented"), ignore)] #[test] diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index e4d7fdea7..e995cc56c 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (flags) reflink (fs) tmpfs + use crate::common::util::*; #[cfg(not(windows))] use std::fs::set_permissions; @@ -926,7 +928,7 @@ fn test_cp_archive() { let (at, mut ucmd) = at_and_ucmd!(); let ts = time::now().to_timespec(); let previous = FileTime::from_unix_time(ts.sec as i64 - 3600, ts.nsec as u32); - // set the file creation/modif an hour ago + // set the file creation/modification an hour ago filetime::set_file_times( at.plus_as_string(TEST_HELLO_WORLD_SOURCE), previous, @@ -1055,7 +1057,7 @@ fn test_cp_preserve_timestamps() { let (at, mut ucmd) = at_and_ucmd!(); let ts = time::now().to_timespec(); let previous = FileTime::from_unix_time(ts.sec as i64 - 3600, ts.nsec as u32); - // set the file creation/modif an hour ago + // set the file creation/modification an hour ago filetime::set_file_times( at.plus_as_string(TEST_HELLO_WORLD_SOURCE), previous, @@ -1084,11 +1086,11 @@ fn test_cp_preserve_timestamps() { #[test] #[cfg(target_os = "linux")] -fn test_cp_dont_preserve_timestamps() { +fn test_cp_no_preserve_timestamps() { let (at, mut ucmd) = at_and_ucmd!(); let ts = time::now().to_timespec(); let previous = FileTime::from_unix_time(ts.sec as i64 - 3600, ts.nsec as u32); - // set the file creation/modif an hour ago + // set the file creation/modification an hour ago filetime::set_file_times( at.plus_as_string(TEST_HELLO_WORLD_SOURCE), previous, @@ -1181,7 +1183,7 @@ fn test_cp_one_file_system() { scene.cmd("umount").arg(mountpoint_path).succeeds(); assert!(!at_dst.file_exists(TEST_MOUNT_OTHER_FILESYSTEM_FILE)); - // Check if the other files were copied from the source folder hirerarchy + // Check if the other files were copied from the source folder hierarchy for entry in WalkDir::new(at_src.as_string()) { let entry = entry.unwrap(); let relative_src = entry diff --git a/tests/by-util/test_csplit.rs b/tests/by-util/test_csplit.rs index ae0885ff8..7eeb584eb 100644 --- a/tests/by-util/test_csplit.rs +++ b/tests/by-util/test_csplit.rs @@ -904,7 +904,7 @@ fn test_no_match() { } #[test] -fn test_too_small_linenum() { +fn test_too_small_line_num() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "/20/", "10", "/40/"]) .succeeds() @@ -921,7 +921,7 @@ fn test_too_small_linenum() { } #[test] -fn test_too_small_linenum_equal() { +fn test_too_small_line_num_equal() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "/20/", "20"]) .succeeds() @@ -937,7 +937,7 @@ fn test_too_small_linenum_equal() { } #[test] -fn test_too_small_linenum_elided() { +fn test_too_small_line_num_elided() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "-z", "/20/", "10", "/40/"]) .succeeds() @@ -953,7 +953,7 @@ fn test_too_small_linenum_elided() { } #[test] -fn test_too_small_linenum_negative_offset() { +fn test_too_small_line_num_negative_offset() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "/20/-5", "10", "/40/"]) .succeeds() @@ -970,7 +970,7 @@ fn test_too_small_linenum_negative_offset() { } #[test] -fn test_too_small_linenum_twice() { +fn test_too_small_line_num_twice() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "/20/", "10", "15", "/40/"]) .succeeds() @@ -988,7 +988,7 @@ fn test_too_small_linenum_twice() { } #[test] -fn test_too_small_linenum_repeat() { +fn test_too_small_line_num_repeat() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "/20/", "10", "{*}"]) .fails() @@ -1020,7 +1020,7 @@ fn test_too_small_linenum_repeat() { } #[test] -fn test_linenum_out_of_range1() { +fn test_line_num_out_of_range1() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "100"]) .fails() @@ -1046,7 +1046,7 @@ fn test_linenum_out_of_range1() { } #[test] -fn test_linenum_out_of_range2() { +fn test_line_num_out_of_range2() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "10", "100"]) .fails() @@ -1073,7 +1073,7 @@ fn test_linenum_out_of_range2() { } #[test] -fn test_linenum_out_of_range3() { +fn test_line_num_out_of_range3() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "40", "{2}"]) .fails() @@ -1100,7 +1100,7 @@ fn test_linenum_out_of_range3() { } #[test] -fn test_linenum_out_of_range4() { +fn test_line_num_out_of_range4() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "40", "{*}"]) .fails() @@ -1141,7 +1141,7 @@ fn test_skip_to_match_negative_offset_before_a_match() { } #[test] -fn test_skip_to_match_negative_offset_before_a_linenum() { +fn test_skip_to_match_negative_offset_before_a_line_num() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "/20/-10", "15"]) .succeeds() @@ -1247,7 +1247,7 @@ fn test_up_to_match_context_underflow() { // the offset is out of range because of the first pattern // NOTE: output different than gnu's: the empty split is written but the rest of the input file is not #[test] -fn test_linenum_range_with_up_to_match1() { +fn test_line_num_range_with_up_to_match1() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "10", "/12/-5"]) .fails() @@ -1277,7 +1277,7 @@ fn test_linenum_range_with_up_to_match1() { // the offset is out of range because more lines are needed than physically available // NOTE: output different than gnu's: the empty split is not written but the rest of the input file is #[test] -fn test_linenum_range_with_up_to_match2() { +fn test_line_num_range_with_up_to_match2() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "10", "/12/-15"]) .fails() @@ -1306,7 +1306,7 @@ fn test_linenum_range_with_up_to_match2() { // NOTE: output different than gnu's: the pattern /10/ is matched but should not #[test] -fn test_linenum_range_with_up_to_match3() { +fn test_line_num_range_with_up_to_match3() { let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["numbers50.txt", "10", "/10/", "-k"]) .fails() diff --git a/tests/by-util/test_date.rs b/tests/by-util/test_date.rs index f4990566a..72747fa66 100644 --- a/tests/by-util/test_date.rs +++ b/tests/by-util/test_date.rs @@ -181,7 +181,7 @@ fn test_date_set_valid_2() { if get_effective_uid() == 0 { let result = new_ucmd!() .arg("--set") - .arg("Sat 20 Mar 2021 14:53:01 AWST") + .arg("Sat 20 Mar 2021 14:53:01 AWST") // spell-checker:disable-line .fails(); result.no_stdout(); assert!(result.stderr_str().starts_with("date: invalid date ")); diff --git a/tests/by-util/test_dircolors.rs b/tests/by-util/test_dircolors.rs index f28074075..fac4161f3 100644 --- a/tests/by-util/test_dircolors.rs +++ b/tests/by-util/test_dircolors.rs @@ -30,14 +30,14 @@ fn test_shell_syntax() { } #[test] -fn test_strutils() { +fn test_str_utils() { let s = " asd#zcv #hk\t\n "; assert_eq!("asd#zcv", s.purify()); let s = "con256asd"; - assert!(s.fnmatch("*[2][3-6][5-9]?sd")); + assert!(s.fnmatch("*[2][3-6][5-9]?sd")); // spell-checker:disable-line - let s = "zxc \t\nqwe jlk hjl"; + let s = "zxc \t\nqwe jlk hjl"; // spell-checker:disable-line let (k, v) = s.split_two(); assert_eq!("zxc", k); assert_eq!("qwe jlk hjl", v); diff --git a/tests/by-util/test_du.rs b/tests/by-util/test_du.rs index e4dca7a61..9e585b03e 100644 --- a/tests/by-util/test_du.rs +++ b/tests/by-util/test_du.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (paths) sublink subwords + use crate::common::util::*; const SUB_DIR: &str = "subdir/deeper"; diff --git a/tests/by-util/test_echo.rs b/tests/by-util/test_echo.rs index 5d1b68e6c..09ed9658f 100644 --- a/tests/by-util/test_echo.rs +++ b/tests/by-util/test_echo.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) araba merci + use crate::common::util::*; #[test] @@ -185,9 +187,9 @@ fn test_multiple_hyphen_values() { #[test] fn test_hyphen_values_inside_string() { new_ucmd!() - .arg("'\"\n'CXXFLAGS=-g -O2'\n\"'") + .arg("'\"\n'CXXFLAGS=-g -O2'\n\"'") // spell-checker:disable-line .succeeds() - .stdout_contains("CXXFLAGS"); + .stdout_contains("CXXFLAGS"); // spell-checker:disable-line } #[test] diff --git a/tests/by-util/test_env.rs b/tests/by-util/test_env.rs index 23bba57a9..4db3b59bd 100644 --- a/tests/by-util/test_env.rs +++ b/tests/by-util/test_env.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) bamf chdir + #[cfg(not(windows))] use std::fs; diff --git a/tests/by-util/test_factor.rs b/tests/by-util/test_factor.rs index 917d19a49..a3f06ea8a 100644 --- a/tests/by-util/test_factor.rs +++ b/tests/by-util/test_factor.rs @@ -6,6 +6,8 @@ // that was distributed with this source code. #![allow(clippy::unreadable_literal)] +// spell-checker:ignore (methods) hexdigest + use crate::common::util::*; use std::time::SystemTime; @@ -27,13 +29,13 @@ fn test_first_100000_integers() { extern crate sha1; let n_integers = 100_000; - let mut instring = String::new(); + let mut input_string = String::new(); for i in 0..=n_integers { - instring.push_str(&(format!("{} ", i))[..]); + input_string.push_str(&(format!("{} ", i))[..]); } - println!("STDIN='{}'", instring); - let result = new_ucmd!().pipe_in(instring.as_bytes()).succeeds(); + println!("STDIN='{}'", input_string); + let result = new_ucmd!().pipe_in(input_string.as_bytes()).succeeds(); // `seq 0 100000 | factor | sha1sum` => "4ed2d8403934fa1c76fe4b84c5d4b8850299c359" let hash_check = sha1::Sha1::from(result.stdout()).hexdigest(); @@ -95,20 +97,20 @@ fn test_random() { }; // build an input and expected output string from factor - let mut instring = String::new(); - let mut outstring = String::new(); + let mut input_string = String::new(); + let mut output_string = String::new(); for _ in 0..NUM_TESTS { let (product, factors) = rand_gt(1 << 63); - instring.push_str(&(format!("{} ", product))[..]); + input_string.push_str(&(format!("{} ", product))[..]); - outstring.push_str(&(format!("{}:", product))[..]); + output_string.push_str(&(format!("{}:", product))[..]); for factor in factors { - outstring.push_str(&(format!(" {}", factor))[..]); + output_string.push_str(&(format!(" {}", factor))[..]); } - outstring.push('\n'); + output_string.push('\n'); } - run(instring.as_bytes(), outstring.as_bytes()); + run(input_string.as_bytes(), output_string.as_bytes()); } #[test] @@ -120,30 +122,30 @@ fn test_random_big() { println!("rng_seed={:?}", rng_seed); let mut rng = SmallRng::seed_from_u64(rng_seed); - let bitrange_1 = Uniform::new(14_usize, 51); + let bit_range_1 = Uniform::new(14_usize, 51); let mut rand_64 = move || { // first, choose a random number of bits for the first factor - let f_bit_1 = bitrange_1.sample(&mut rng); + let f_bit_1 = bit_range_1.sample(&mut rng); // how many more bits do we need? let rem = 64 - f_bit_1; - // we will have a number of additional factors equal to nfacts + 1 - // where nfacts is in [0, floor(rem/14) ) NOTE half-open interval + // we will have a number of additional factors equal to n_facts + 1 + // where n_facts is in [0, floor(rem/14) ) NOTE half-open interval // Each prime factor is at least 14 bits, hence floor(rem/14) - let nfacts = Uniform::new(0_usize, rem / 14).sample(&mut rng); - // we have to distribute extrabits among the (nfacts + 1) values - let extrabits = rem - (nfacts + 1) * 14; + let n_factors = Uniform::new(0_usize, rem / 14).sample(&mut rng); + // we have to distribute extra_bits among the (n_facts + 1) values + let extra_bits = rem - (n_factors + 1) * 14; // (remember, a Range is a half-open interval) - let extrarange = Uniform::new(0_usize, extrabits + 1); + let extra_range = Uniform::new(0_usize, extra_bits + 1); // to generate an even split of this range, generate n-1 random elements // in the range, add the desired total value to the end, sort this list, // and then compute the sequential differences. let mut f_bits = Vec::new(); - for _ in 0..nfacts { - f_bits.push(extrarange.sample(&mut rng)); + for _ in 0..n_factors { + f_bits.push(extra_range.sample(&mut rng)); } - f_bits.push(extrabits); + f_bits.push(extra_bits); f_bits.sort_unstable(); // compute sequential differences here. We leave off the +14 bits @@ -160,59 +162,62 @@ fn test_random_big() { f_bits.push(f_bit_1 - 14); // index of f_bit_1 in PRIMES_BY_BITS let f_bits = f_bits; - let mut nbits = 0; + let mut n_bits = 0; let mut product = 1_u64; let mut factors = Vec::new(); for bit in f_bits { assert!(bit < 37); - nbits += 14 + bit; + n_bits += 14 + bit; let elm = Uniform::new(0, PRIMES_BY_BITS[bit].len()).sample(&mut rng); let factor = PRIMES_BY_BITS[bit][elm]; factors.push(factor); product *= factor; } - assert_eq!(nbits, 64); + assert_eq!(n_bits, 64); factors.sort_unstable(); (product, factors) }; - let mut instring = String::new(); - let mut outstring = String::new(); + let mut input_string = String::new(); + let mut output_string = String::new(); for _ in 0..NUM_TESTS { let (product, factors) = rand_64(); - instring.push_str(&(format!("{} ", product))[..]); + input_string.push_str(&(format!("{} ", product))[..]); - outstring.push_str(&(format!("{}:", product))[..]); + output_string.push_str(&(format!("{}:", product))[..]); for factor in factors { - outstring.push_str(&(format!(" {}", factor))[..]); + output_string.push_str(&(format!(" {}", factor))[..]); } - outstring.push('\n'); + output_string.push('\n'); } - run(instring.as_bytes(), outstring.as_bytes()); + run(input_string.as_bytes(), output_string.as_bytes()); } #[test] fn test_big_primes() { - let mut instring = String::new(); - let mut outstring = String::new(); + let mut input_string = String::new(); + let mut output_string = String::new(); for prime in PRIMES64 { - instring.push_str(&(format!("{} ", prime))[..]); - outstring.push_str(&(format!("{0}: {0}\n", prime))[..]); + input_string.push_str(&(format!("{} ", prime))[..]); + output_string.push_str(&(format!("{0}: {0}\n", prime))[..]); } - run(instring.as_bytes(), outstring.as_bytes()); + run(input_string.as_bytes(), output_string.as_bytes()); } -fn run(instring: &[u8], outstring: &[u8]) { - println!("STDIN='{}'", String::from_utf8_lossy(instring)); - println!("STDOUT(expected)='{}'", String::from_utf8_lossy(outstring)); +fn run(input_string: &[u8], output_string: &[u8]) { + println!("STDIN='{}'", String::from_utf8_lossy(input_string)); + println!( + "STDOUT(expected)='{}'", + String::from_utf8_lossy(output_string) + ); // now run factor new_ucmd!() - .pipe_in(instring) + .pipe_in(input_string) .run() - .stdout_is(String::from_utf8(outstring.to_owned()).unwrap()); + .stdout_is(String::from_utf8(output_string.to_owned()).unwrap()); } const PRIMES_BY_BITS: &[&[u64]] = &[ diff --git a/tests/by-util/test_fold.rs b/tests/by-util/test_fold.rs index 5224a50dc..1acdadac1 100644 --- a/tests/by-util/test_fold.rs +++ b/tests/by-util/test_fold.rs @@ -282,7 +282,7 @@ fn test_backspace_is_not_word_boundary() { .args(&["-w10", "-s"]) .pipe_in("foobar\x086789abcdef") .succeeds() - .stdout_is("foobar\x086789a\nbcdef"); + .stdout_is("foobar\x086789a\nbcdef"); // spell-checker:disable-line } #[test] @@ -291,7 +291,7 @@ fn test_carriage_return_should_be_preserved() { } #[test] -fn test_carriage_return_overwrriten_char_should_be_preserved() { +fn test_carriage_return_overwritten_char_should_be_preserved() { new_ucmd!().pipe_in("x\ry").succeeds().stdout_is("x\ry"); } @@ -308,9 +308,9 @@ fn test_carriage_return_should_reset_column_count() { fn test_carriage_return_is_not_word_boundary() { new_ucmd!() .args(&["-w6", "-s"]) - .pipe_in("fizz\rbuzz\rfizzbuzz") + .pipe_in("fizz\rbuzz\rfizzbuzz") // spell-checker:disable-line .succeeds() - .stdout_is("fizz\rbuzz\rfizzbu\nzz"); + .stdout_is("fizz\rbuzz\rfizzbu\nzz"); // spell-checker:disable-line } // @@ -496,7 +496,7 @@ fn test_bytewise_backspace_is_not_word_boundary() { .args(&["-w10", "-s", "-b"]) .pipe_in("foobar\x0889abcdef") .succeeds() - .stdout_is("foobar\x0889a\nbcdef"); + .stdout_is("foobar\x0889a\nbcdef"); // spell-checker:disable-line } #[test] @@ -509,7 +509,7 @@ fn test_bytewise_carriage_return_should_be_preserved() { } #[test] -fn test_bytewise_carriage_return_overwrriten_char_should_be_preserved() { +fn test_bytewise_carriage_return_overwritten_char_should_be_preserved() { new_ucmd!() .arg("-b") .pipe_in("x\ry") @@ -530,9 +530,9 @@ fn test_bytewise_carriage_return_should_not_reset_column_count() { fn test_bytewise_carriage_return_is_not_word_boundary() { new_ucmd!() .args(&["-w6", "-s", "-b"]) - .pipe_in("fizz\rbuzz\rfizzbuzz") + .pipe_in("fizz\rbuzz\rfizzbuzz") // spell-checker:disable-line .succeeds() - .stdout_is("fizz\rb\nuzz\rfi\nzzbuzz"); + .stdout_is("fizz\rb\nuzz\rfi\nzzbuzz"); // spell-checker:disable-line } #[test] fn test_obsolete_syntax() { diff --git a/tests/by-util/test_head.rs b/tests/by-util/test_head.rs index cf7c9c2ee..7daa80e3a 100755 --- a/tests/by-util/test_head.rs +++ b/tests/by-util/test_head.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) bogusfile emptyfile + use crate::common::util::*; static INPUT: &str = "lorem_ipsum.txt"; diff --git a/tests/by-util/test_install.rs b/tests/by-util/test_install.rs index 6da357170..3ab5cbdfb 100644 --- a/tests/by-util/test_install.rs +++ b/tests/by-util/test_install.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) helloworld objdump + use crate::common::util::*; use filetime::FileTime; use rust_users::*; diff --git a/tests/by-util/test_join.rs b/tests/by-util/test_join.rs index a8f046851..8dbdadba7 100644 --- a/tests/by-util/test_join.rs +++ b/tests/by-util/test_join.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) autoformat + use crate::common::util::*; #[test] @@ -141,7 +143,7 @@ fn new_line_separated() { } #[test] -fn multitab_character() { +fn tab_multi_character() { new_ucmd!() .arg("semicolon_fields_1.txt") .arg("semicolon_fields_2.txt") diff --git a/tests/by-util/test_kill.rs b/tests/by-util/test_kill.rs index 637aea9a2..fe5d4557a 100644 --- a/tests/by-util/test_kill.rs +++ b/tests/by-util/test_kill.rs @@ -79,9 +79,10 @@ fn test_kill_list_one_signal_from_name() { #[test] fn test_kill_set_bad_signal_name() { + // spell-checker:disable-line new_ucmd!() .arg("-s") - .arg("IAMNOTASIGNAL") + .arg("IAMNOTASIGNAL") // spell-checker:disable-line .fails() .stderr_contains("unknown signal"); } diff --git a/tests/by-util/test_ln.rs b/tests/by-util/test_ln.rs index f2508ecbf..e475e3608 100644 --- a/tests/by-util/test_ln.rs +++ b/tests/by-util/test_ln.rs @@ -65,10 +65,10 @@ fn test_symlink_circular() { } #[test] -fn test_symlink_dont_overwrite() { +fn test_symlink_do_not_overwrite() { let (at, mut ucmd) = at_and_ucmd!(); - let file = "test_symlink_dont_overwrite"; - let link = "test_symlink_dont_overwrite_link"; + let file = "test_symlink_do_not_overwrite"; + let link = "test_symlink_do_not_overwrite_link"; at.touch(file); at.touch(link); @@ -120,7 +120,7 @@ fn test_symlink_interactive() { scene .ucmd() .args(&["-i", "-s", file, link]) - .pipe_in("Yesh") + .pipe_in("Yesh") // spell-checker:disable-line .succeeds() .no_stderr(); diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 9614f561e..20c6b913d 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) READMECAREFULLY birthtime doesntexist oneline somebackup somefile somegroup somehiddenbackup somehiddenfile + #[cfg(unix)] extern crate unix_socket; use crate::common::util::*; @@ -939,7 +941,7 @@ fn test_ls_color() { let a_with_colors = "\x1b[1;34ma\x1b[0m"; let z_with_colors = "\x1b[1;34mz\x1b[0m"; - let nested_dir_with_colors = "\x1b[1;34mnested_dir\x1b[0m"; + let nested_dir_with_colors = "\x1b[1;34mnested_dir\x1b[0m"; // spell-checker:disable-line // Color is disabled by default let result = scene.ucmd().succeeds(); diff --git a/tests/by-util/test_mktemp.rs b/tests/by-util/test_mktemp.rs index d0737764f..d601bad5b 100644 --- a/tests/by-util/test_mktemp.rs +++ b/tests/by-util/test_mktemp.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) gpghome + use crate::common::util::*; use std::path::PathBuf; @@ -8,8 +10,8 @@ static TEST_TEMPLATE2: &str = "temp"; static TEST_TEMPLATE3: &str = "tempX"; static TEST_TEMPLATE4: &str = "tempXX"; static TEST_TEMPLATE5: &str = "tempXXX"; -static TEST_TEMPLATE6: &str = "tempXXXlate"; -static TEST_TEMPLATE7: &str = "XXXtemplate"; +static TEST_TEMPLATE6: &str = "tempXXXlate"; // spell-checker:disable-line +static TEST_TEMPLATE7: &str = "XXXtemplate"; // spell-checker:disable-line #[cfg(unix)] static TEST_TEMPLATE8: &str = "tempXXXl/ate"; #[cfg(windows)] diff --git a/tests/by-util/test_more.rs b/tests/by-util/test_more.rs index cc778f0b4..9b28ee24e 100644 --- a/tests/by-util/test_more.rs +++ b/tests/by-util/test_more.rs @@ -5,12 +5,13 @@ fn test_more_no_arg() { // Reading from stdin is now supported, so this must succeed if atty::is(atty::Stream::Stdout) { new_ucmd!().succeeds(); - } else {} + } else { + } } #[test] fn test_more_dir_arg() { - // Run the test only if there's a valud terminal, else do nothing + // Run the test only if there's a valid terminal, else do nothing // Maybe we could capture the error, i.e. "Device not found" in that case // but I am leaving this for later if atty::is(atty::Stream::Stdout) { @@ -19,5 +20,6 @@ fn test_more_dir_arg() { const EXPECTED_ERROR_MESSAGE: &str = "more: '.' is a directory.\nTry 'more --help' for more information."; assert_eq!(result.stderr_str().trim(), EXPECTED_ERROR_MESSAGE); - } else {} + } else { + } } diff --git a/tests/by-util/test_mv.rs b/tests/by-util/test_mv.rs index beb8f61b9..2f35bf5eb 100644 --- a/tests/by-util/test_mv.rs +++ b/tests/by-util/test_mv.rs @@ -171,7 +171,7 @@ fn test_mv_interactive() { .arg("-i") .arg(file_a) .arg(file_b) - .pipe_in("Yesh") + .pipe_in("Yesh") // spell-checker:disable-line .succeeds() .no_stderr(); diff --git a/tests/by-util/test_nice.rs b/tests/by-util/test_nice.rs index 9e004b98b..25886de78 100644 --- a/tests/by-util/test_nice.rs +++ b/tests/by-util/test_nice.rs @@ -17,7 +17,7 @@ fn test_negative_adjustment() { let res = new_ucmd!().args(&["-n", "-1", "true"]).run(); assert!(res .stderr_str() - .starts_with("nice: warning: setpriority: Permission denied")); + .starts_with("nice: warning: setpriority: Permission denied")); // spell-checker:disable-line } #[test] diff --git a/tests/by-util/test_nl.rs b/tests/by-util/test_nl.rs index 3ca039d19..ce3014311 100644 --- a/tests/by-util/test_nl.rs +++ b/tests/by-util/test_nl.rs @@ -1,7 +1,7 @@ use crate::common::util::*; #[test] -fn test_stdin_nonewline() { +fn test_stdin_no_newline() { new_ucmd!() .pipe_in("No Newline") .run() @@ -41,6 +41,7 @@ fn test_padding_with_overflow() { #[test] fn test_sections_and_styles() { + // spell-checker:disable for &(fixture, output) in &[ ( "section.txt", @@ -63,4 +64,5 @@ fn test_sections_and_styles() { .run() .stdout_is(output); } + // spell-checker:enable } diff --git a/tests/by-util/test_numfmt.rs b/tests/by-util/test_numfmt.rs index b52dbc359..bb29d431e 100644 --- a/tests/by-util/test_numfmt.rs +++ b/tests/by-util/test_numfmt.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (paths) gnutest + use crate::common::util::*; #[test] @@ -231,7 +233,7 @@ fn test_should_skip_leading_space_from_stdin() { .run() .stdout_is("2048\n"); - // multiline + // multi-line new_ucmd!() .args(&["--from=auto"]) .pipe_in("\t1Ki\n 2K") diff --git a/tests/by-util/test_od.rs b/tests/by-util/test_od.rs index fa947aa6e..c21c683dc 100644 --- a/tests/by-util/test_od.rs +++ b/tests/by-util/test_od.rs @@ -8,7 +8,7 @@ use std::fs::File; use std::io::Write; use std::path::Path; -// octal dump of 'abcdefghijklmnopqrstuvwxyz\n' +// octal dump of 'abcdefghijklmnopqrstuvwxyz\n' // spell-checker:disable-line static ALPHA_OUT: &str = " 0000000 061141 062143 063145 064147 065151 066153 067155 070157 0000020 071161 072163 073165 074167 075171 000012 @@ -16,7 +16,7 @@ static ALPHA_OUT: &str = " "; // XXX We could do a better job of ensuring that we have a fresh temp dir to ourselves, -// not a general one full of other proc's leftovers. +// not a general one full of other process leftovers. // Test that od can read one file and dump with default format #[test] @@ -29,6 +29,7 @@ fn test_file() { { let mut f = File::create(&file).unwrap(); + // spell-checker:disable-next-line if f.write_all(b"abcdefghijklmnopqrstuvwxyz\n").is_err() { panic!("Test setup failed - could not write file"); } @@ -55,6 +56,7 @@ fn test_2files() { println!("number: {} letter:{}", n, a); } + // spell-checker:disable-next-line for &(path, data) in &[(&file1, "abcdefghijklmnop"), (&file2, "qrstuvwxyz\n")] { let mut f = File::create(&path).unwrap(); if f.write_all(data.as_bytes()).is_err() { @@ -79,7 +81,7 @@ fn test_2files() { fn test_no_file() { let temp = env::temp_dir(); let tmpdir = Path::new(&temp); - let file = tmpdir.join("}surely'none'would'thus'a'file'name"); + let file = tmpdir.join("}surely'none'would'thus'a'file'name"); // spell-checker:disable-line new_ucmd!().arg(file.as_os_str()).fails(); } @@ -87,7 +89,7 @@ fn test_no_file() { // Test that od reads from stdin instead of a file #[test] fn test_from_stdin() { - let input = "abcdefghijklmnopqrstuvwxyz\n"; + let input = "abcdefghijklmnopqrstuvwxyz\n"; // spell-checker:disable-line new_ucmd!() .arg("--endian=little") .run_piped_stdin(input.as_bytes()) @@ -104,6 +106,7 @@ fn test_from_mixed() { let file1 = tmpdir.join("test-1"); let file3 = tmpdir.join("test-3"); + // spell-checker:disable-next-line let (data1, data2, data3) = ("abcdefg", "hijklmnop", "qrstuvwxyz\n"); for &(path, data) in &[(&file1, data1), (&file3, data3)] { let mut f = File::create(&path).unwrap(); @@ -125,7 +128,7 @@ fn test_from_mixed() { #[test] fn test_multiple_formats() { - let input = "abcdefghijklmnopqrstuvwxyz\n"; + let input = "abcdefghijklmnopqrstuvwxyz\n"; // spell-checker:disable-line new_ucmd!() .arg("-c") .arg("-b") @@ -145,6 +148,7 @@ fn test_multiple_formats() { #[test] fn test_dec() { + // spell-checker:ignore (words) 0xffu8 xffu let input = [ 0u8, 0u8, 1u8, 0u8, 2u8, 0u8, 3u8, 0u8, 0xffu8, 0x7fu8, 0x00u8, 0x80u8, 0x01u8, 0x80u8, ]; @@ -166,12 +170,14 @@ fn test_dec() { #[test] fn test_hex16() { let input: [u8; 9] = [0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xff]; + // spell-checker:disable let expected_output = unindent( " 0000000 2301 6745 ab89 efcd 00ff 0000011 ", ); + // spell-checker:enable new_ucmd!() .arg("--endian=little") .arg("-x") @@ -288,7 +294,7 @@ fn test_multibyte() { new_ucmd!() .arg("-c") .arg("-w12") - .run_piped_stdin("Universität Tübingen \u{1B000}".as_bytes()) + .run_piped_stdin("Universität Tübingen \u{1B000}".as_bytes()) // spell-checker:disable-line .success() .no_stderr() .stdout_is(unindent( @@ -487,7 +493,7 @@ fn test_alignment_Fx() { } #[test] -fn test_maxuint() { +fn test_max_uint() { let input = [0xFFu8; 8]; let expected_output = unindent( " @@ -505,7 +511,7 @@ fn test_maxuint() { new_ucmd!() .arg("--format=o8") - .arg("-Oobtu8") + .arg("-Oobtu8") // spell-checker:disable-line .arg("-Dd") .arg("--format=u1") .run_piped_stdin(&input[..]) @@ -583,7 +589,7 @@ fn test_invalid_offset() { #[test] fn test_skip_bytes() { - let input = "abcdefghijklmnopq"; + let input = "abcdefghijklmnopq"; // spell-checker:disable-line new_ucmd!() .arg("-c") .arg("--skip-bytes=5") @@ -609,7 +615,7 @@ fn test_skip_bytes_error() { #[test] fn test_read_bytes() { - let input = "abcdefghijklmnopqrstuvwxyz\n12345678"; + let input = "abcdefghijklmnopqrstuvwxyz\n12345678"; // spell-checker:disable-line new_ucmd!() .arg("--endian=little") .arg("--read-bytes=27") @@ -626,7 +632,7 @@ fn test_ascii_dump() { 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, 0xff, ]; new_ucmd!() - .arg("-tx1zacz") + .arg("-tx1zacz") // spell-checker:disable-line .run_piped_stdin(&input[..]) .no_stderr() .success() @@ -645,7 +651,7 @@ fn test_ascii_dump() { #[test] fn test_filename_parsing() { - // files "a" and "x" both exists, but are no filenames in the commandline below + // files "a" and "x" both exists, but are no filenames in the command line below // "-f" must be treated as a filename, it contains the text: minus lowercase f // so "-f" should not be interpreted as a formatting option. new_ucmd!() @@ -668,7 +674,7 @@ fn test_filename_parsing() { #[test] fn test_stdin_offset() { - let input = "abcdefghijklmnopq"; + let input = "abcdefghijklmnopq"; // spell-checker:disable-line new_ucmd!() .arg("-c") .arg("+5") @@ -703,7 +709,7 @@ fn test_file_offset() { #[test] fn test_traditional() { // note gnu od does not align both lines - let input = "abcdefghijklmnopq"; + let input = "abcdefghijklmnopq"; // spell-checker:disable-line new_ucmd!() .arg("--traditional") .arg("-a") @@ -726,7 +732,7 @@ fn test_traditional() { #[test] fn test_traditional_with_skip_bytes_override() { // --skip-bytes is ignored in this case - let input = "abcdefghijklmnop"; + let input = "abcdefghijklmnop"; // spell-checker:disable-line new_ucmd!() .arg("--traditional") .arg("--skip-bytes=10") @@ -746,7 +752,7 @@ fn test_traditional_with_skip_bytes_override() { #[test] fn test_traditional_with_skip_bytes_non_override() { // no offset specified in the traditional way, so --skip-bytes is used - let input = "abcdefghijklmnop"; + let input = "abcdefghijklmnop"; // spell-checker:disable-line new_ucmd!() .arg("--traditional") .arg("--skip-bytes=10") @@ -776,7 +782,7 @@ fn test_traditional_error() { #[test] fn test_traditional_only_label() { - let input = "abcdefghijklmnopqrstuvwxyz"; + let input = "abcdefghijklmnopqrstuvwxyz"; // spell-checker:disable-line new_ucmd!() .arg("-An") .arg("--traditional") diff --git a/tests/by-util/test_pinky.rs b/tests/by-util/test_pinky.rs index ccabb7345..0813e5e1b 100644 --- a/tests/by-util/test_pinky.rs +++ b/tests/by-util/test_pinky.rs @@ -9,24 +9,24 @@ pub use self::pinky::*; #[test] fn test_capitalize() { - assert_eq!("Zbnmasd", "zbnmasd".capitalize()); - assert_eq!("Abnmasd", "Abnmasd".capitalize()); - assert_eq!("1masd", "1masd".capitalize()); + assert_eq!("Zbnmasd", "zbnmasd".capitalize()); // spell-checker:disable-line + assert_eq!("Abnmasd", "Abnmasd".capitalize()); // spell-checker:disable-line + assert_eq!("1masd", "1masd".capitalize()); // spell-checker:disable-line assert_eq!("", "".capitalize()); } #[test] fn test_long_format() { - let ulogin = "root"; - let pw: Passwd = Passwd::locate(ulogin).unwrap(); + let login = "root"; + let pw: Passwd = Passwd::locate(login).unwrap(); let real_name = pw.user_info().replace("&", &pw.name().capitalize()); new_ucmd!() .arg("-l") - .arg(ulogin) + .arg(login) .succeeds() .stdout_is(format!( "Login name: {:<28}In real life: {}\nDirectory: {:<29}Shell: {}\n\n", - ulogin, + login, real_name, pw.user_dir(), pw.user_shell() @@ -34,11 +34,11 @@ fn test_long_format() { new_ucmd!() .arg("-lb") - .arg(ulogin) + .arg(login) .succeeds() .stdout_is(format!( "Login name: {:<28}In real life: {1}\n\n", - ulogin, real_name + login, real_name )); } diff --git a/tests/by-util/test_printf.rs b/tests/by-util/test_printf.rs index 1e3e21d0c..b5c9dc3ed 100644 --- a/tests/by-util/test_printf.rs +++ b/tests/by-util/test_printf.rs @@ -43,12 +43,12 @@ fn escaped_octal() { } #[test] -fn escaped_unicode_fourdigit() { +fn escaped_unicode_four_digit() { new_ucmd!().args(&["\\u0125"]).succeeds().stdout_only("ĥ"); } #[test] -fn escaped_unicode_eightdigit() { +fn escaped_unicode_eight_digit() { new_ucmd!() .args(&["\\U00000125"]) .succeeds() @@ -77,7 +77,7 @@ fn sub_string() { } #[test] -fn sub_multifield() { +fn sub_multi_field() { new_ucmd!() .args(&["%s %s", "hello", "world"]) .succeeds() @@ -85,7 +85,7 @@ fn sub_multifield() { } #[test] -fn sub_repeat_formatstr() { +fn sub_repeat_format_str() { new_ucmd!() .args(&["%s.", "hello", "world"]) .succeeds() @@ -101,7 +101,7 @@ fn sub_string_ignore_escapes() { } #[test] -fn sub_bstring_handle_escapes() { +fn sub_b_string_handle_escapes() { new_ucmd!() .args(&["hello %b", "\\tworld"]) .succeeds() @@ -109,7 +109,7 @@ fn sub_bstring_handle_escapes() { } #[test] -fn sub_bstring_ignore_subs() { +fn sub_b_string_ignore_subs() { new_ucmd!() .args(&["hello %b", "world %% %i"]) .succeeds() @@ -133,7 +133,7 @@ fn sub_num_int() { } #[test] -fn sub_num_int_minwidth() { +fn sub_num_int_min_width() { new_ucmd!() .args(&["twenty is %1i", "20"]) .succeeds() @@ -181,11 +181,11 @@ fn sub_num_int_hex_in_neg() { } #[test] -fn sub_num_int_charconst_in() { +fn sub_num_int_char_const_in() { new_ucmd!() - .args(&["ninetyseven is %i", "'a"]) + .args(&["ninety seven is %i", "'a"]) .succeeds() - .stdout_only("ninetyseven is 97"); + .stdout_only("ninety seven is 97"); } #[test] @@ -287,7 +287,7 @@ fn sub_num_hex_float_upper() { } #[test] -fn sub_minwidth() { +fn sub_min_width() { new_ucmd!() .args(&["hello %7s", "world"]) .succeeds() @@ -295,7 +295,7 @@ fn sub_minwidth() { } #[test] -fn sub_minwidth_negative() { +fn sub_min_width_negative() { new_ucmd!() .args(&["hello %-7s", "world"]) .succeeds() @@ -327,7 +327,7 @@ fn sub_int_leading_zeroes() { } #[test] -fn sub_int_leading_zeroes_prio() { +fn sub_int_leading_zeroes_padded() { new_ucmd!() .args(&["%5.4i", "11"]) .succeeds() @@ -359,7 +359,7 @@ fn sub_float_no_octal_in() { } #[test] -fn sub_any_asterisk_firstparam() { +fn sub_any_asterisk_first_param() { new_ucmd!() .args(&["%*i", "3", "11", "4", "12"]) .succeeds() @@ -401,7 +401,7 @@ fn sub_any_asterisk_hex_arg() { #[test] fn sub_any_specifiers_no_params() { new_ucmd!() - .args(&["%ztlhLji", "3"]) + .args(&["%ztlhLji", "3"]) //spell-checker:disable-line .succeeds() .stdout_only("3"); } @@ -409,7 +409,7 @@ fn sub_any_specifiers_no_params() { #[test] fn sub_any_specifiers_after_first_param() { new_ucmd!() - .args(&["%0ztlhLji", "3"]) + .args(&["%0ztlhLji", "3"]) //spell-checker:disable-line .succeeds() .stdout_only("3"); } @@ -417,7 +417,7 @@ fn sub_any_specifiers_after_first_param() { #[test] fn sub_any_specifiers_after_period() { new_ucmd!() - .args(&["%0.ztlhLji", "3"]) + .args(&["%0.ztlhLji", "3"]) //spell-checker:disable-line .succeeds() .stdout_only("3"); } @@ -425,7 +425,7 @@ fn sub_any_specifiers_after_period() { #[test] fn sub_any_specifiers_after_second_param() { new_ucmd!() - .args(&["%0.0ztlhLji", "3"]) + .args(&["%0.0ztlhLji", "3"]) //spell-checker:disable-line .succeeds() .stdout_only("3"); } diff --git a/tests/by-util/test_ptx.rs b/tests/by-util/test_ptx.rs index e44943bfa..c17d473f5 100644 --- a/tests/by-util/test_ptx.rs +++ b/tests/by-util/test_ptx.rs @@ -1,43 +1,43 @@ use crate::common::util::*; #[test] -fn gnu_ext_disabled_roff_no_ref() { +fn gnu_ext_disabled_rightward_no_ref() { new_ucmd!() .args(&["-G", "-R", "input"]) .succeeds() - .stdout_only_fixture("gnu_ext_disabled_roff_no_ref.expected"); + .stdout_only_fixture("gnu_ext_disabled_rightward_no_ref.expected"); } #[test] -fn gnu_ext_disabled_roff_no_ref_empty_word_regexp() { +fn gnu_ext_disabled_rightward_no_ref_empty_word_regexp() { new_ucmd!() .args(&["-G", "-R", "-W", "", "input"]) .succeeds() - .stdout_only_fixture("gnu_ext_disabled_roff_no_ref.expected"); + .stdout_only_fixture("gnu_ext_disabled_rightward_no_ref.expected"); } #[test] -fn gnu_ext_disabled_roff_no_ref_word_regexp_exc_space() { +fn gnu_ext_disabled_rightward_no_ref_word_regexp_exc_space() { new_ucmd!() .args(&["-G", "-R", "-W", "[^\t\n]+", "input"]) .succeeds() - .stdout_only_fixture("gnu_ext_disabled_roff_no_ref_word_regexp_exc_space.expected"); + .stdout_only_fixture("gnu_ext_disabled_rightward_no_ref_word_regexp_exc_space.expected"); } #[test] -fn gnu_ext_disabled_roff_input_ref() { +fn gnu_ext_disabled_rightward_input_ref() { new_ucmd!() .args(&["-G", "-r", "-R", "input"]) .succeeds() - .stdout_only_fixture("gnu_ext_disabled_roff_input_ref.expected"); + .stdout_only_fixture("gnu_ext_disabled_rightward_input_ref.expected"); } #[test] -fn gnu_ext_disabled_roff_auto_ref() { +fn gnu_ext_disabled_rightward_auto_ref() { new_ucmd!() .args(&["-G", "-A", "-R", "input"]) .succeeds() - .stdout_only_fixture("gnu_ext_disabled_roff_auto_ref.expected"); + .stdout_only_fixture("gnu_ext_disabled_rightward_auto_ref.expected"); } #[test] diff --git a/tests/by-util/test_pwd.rs b/tests/by-util/test_pwd.rs index b6a6c87a4..2779b9e62 100644 --- a/tests/by-util/test_pwd.rs +++ b/tests/by-util/test_pwd.rs @@ -9,5 +9,5 @@ fn test_default() { #[test] fn test_failed() { let (_at, mut ucmd) = at_and_ucmd!(); - ucmd.arg("willfail").fails(); + ucmd.arg("will-fail").fails(); } diff --git a/tests/by-util/test_relpath.rs b/tests/by-util/test_relpath.rs index b9c07fb12..44a685c90 100644 --- a/tests/by-util/test_relpath.rs +++ b/tests/by-util/test_relpath.rs @@ -115,12 +115,12 @@ fn test_relpath_with_from_with_d() { #[cfg(not(windows))] assert!(Path::new(&_result_stdout).is_relative()); - // d is not part of subpath -> expect absolut path + // d is not part of subpath -> expect absolute path _result_stdout = scene .ucmd() .arg(to) .arg(from) - .arg("-dnon_existing") + .arg("-dnon_existing") // spell-checker:disable-line .succeeds() .stdout_move_str(); assert!(Path::new(&_result_stdout).is_absolute()); @@ -166,11 +166,11 @@ fn test_relpath_no_from_with_d() { #[cfg(not(windows))] assert!(Path::new(&_result_stdout).is_relative()); - // d is not part of subpath -> expect absolut path + // d is not part of subpath -> expect absolute path let result_stdout = scene .ucmd() .arg(to) - .arg("-dnon_existing") + .arg("-dnon_existing") // spell-checker:disable-line .succeeds() .stdout_move_str(); assert!(Path::new(&result_stdout).is_absolute()); diff --git a/tests/by-util/test_rm.rs b/tests/by-util/test_rm.rs index 2a87038d5..0592be244 100644 --- a/tests/by-util/test_rm.rs +++ b/tests/by-util/test_rm.rs @@ -65,7 +65,7 @@ fn test_rm_interactive() { .arg("-i") .arg(file_a) .arg(file_b) - .pipe_in("Yesh") + .pipe_in("Yesh") // spell-checker:disable-line .succeeds(); assert!(!at.file_exists(file_a)); diff --git a/tests/by-util/test_shuf.rs b/tests/by-util/test_shuf.rs index 106d80a39..cbc01f8cd 100644 --- a/tests/by-util/test_shuf.rs +++ b/tests/by-util/test_shuf.rs @@ -19,7 +19,7 @@ fn test_output_is_random_permutation() { .map(|x| x.parse().unwrap()) .collect(); result_seq.sort_unstable(); - assert_ne!(result.stdout_str(), input, "Output is not randomised"); + assert_ne!(result.stdout_str(), input, "Output is not randomized"); assert_eq!(result_seq, input_seq, "Output is not a permutation"); } diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index 588ce86bd..d2b447925 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (words) ints + use crate::common::util::*; fn test_helper(file_name: &str, possible_args: &[&str]) { @@ -61,7 +63,7 @@ fn test_ext_sort_stable() { } #[test] -fn test_extsort_zero_terminated() { +fn test_ext_sort_zero_terminated() { new_ucmd!() .arg("-z") .arg("-S") @@ -96,7 +98,7 @@ fn test_human_numeric_whitespace() { // This tests where serde often fails when reading back JSON // if it finds a null value #[test] -fn test_extsort_as64_bailout() { +fn test_ext_sort_as64_bailout() { new_ucmd!() .arg("-g") .arg("-S 5K") @@ -290,10 +292,10 @@ fn test_dictionary_order() { fn test_dictionary_order2() { for non_dictionary_order2_param in &["-d"] { new_ucmd!() - .pipe_in("a👦🏻aa b\naaaa b") - .arg(non_dictionary_order2_param) + .pipe_in("a👦🏻aa b\naaaa b") // spell-checker:disable-line + .arg(non_dictionary_order2_param) // spell-checker:disable-line .succeeds() - .stdout_only("a👦🏻aa b\naaaa b\n"); + .stdout_only("a👦🏻aa b\naaaa b\n"); // spell-checker:disable-line } } @@ -301,10 +303,10 @@ fn test_dictionary_order2() { fn test_non_printing_chars() { for non_printing_chars_param in &["-i"] { new_ucmd!() - .pipe_in("a👦🏻aa\naaaa") - .arg(non_printing_chars_param) + .pipe_in("a👦🏻aa\naaaa") // spell-checker:disable-line + .arg(non_printing_chars_param) // spell-checker:disable-line .succeeds() - .stdout_only("a👦🏻aa\naaaa\n"); + .stdout_only("a👦🏻aa\naaaa\n"); // spell-checker:disable-line } } @@ -592,7 +594,7 @@ fn test_keys_ignore_flag() { } #[test] -fn test_doesnt_inherit_key_settings() { +fn test_does_not_inherit_key_settings() { let input = " 1 2 10 diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 1ff8bd8f2..85b28326b 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -242,7 +242,7 @@ fn test_filter() { .succeeds(); // assert all characters are 'i' / no character is not 'i' - // (assert that command succeded) + // (assert that command succeeded) let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); assert!( glob.collate().iter().find(|&&c| { @@ -265,7 +265,7 @@ fn test_filter_with_env_var_set() { let n_lines = 3; RandomFile::new(&at, name).add_lines(n_lines); - let env_var_value = "somevalue"; + let env_var_value = "some-value"; env::set_var("FILE", &env_var_value); ucmd.args(&[format!("--filter={}", "cat > $FILE").as_str(), name]) .succeeds(); diff --git a/tests/by-util/test_stat.rs b/tests/by-util/test_stat.rs index 6935cc7f9..89dd96752 100644 --- a/tests/by-util/test_stat.rs +++ b/tests/by-util/test_stat.rs @@ -6,20 +6,20 @@ extern crate stat; pub use self::stat::*; #[test] -fn test_scanutil() { +fn test_scanners() { assert_eq!(Some((-5, 2)), "-5zxc".scan_num::()); assert_eq!(Some((51, 2)), "51zxc".scan_num::()); assert_eq!(Some((192, 4)), "+192zxc".scan_num::()); assert_eq!(None, "z192zxc".scan_num::()); assert_eq!(Some(('a', 3)), "141zxc".scan_char(8)); - assert_eq!(Some(('\n', 2)), "12qzxc".scan_char(8)); - assert_eq!(Some(('\r', 1)), "dqzxc".scan_char(16)); - assert_eq!(None, "z2qzxc".scan_char(8)); + assert_eq!(Some(('\n', 2)), "12qzxc".scan_char(8)); // spell-checker:disable-line + assert_eq!(Some(('\r', 1)), "dqzxc".scan_char(16)); // spell-checker:disable-line + assert_eq!(None, "z2qzxc".scan_char(8)); // spell-checker:disable-line } #[test] -fn test_groupnum() { +fn test_group_num() { assert_eq!("12,379,821,234", group_num("12379821234")); assert_eq!("21,234", group_num("21234")); assert_eq!("821,234", group_num("821234")); @@ -97,13 +97,13 @@ fn test_invalid_option() { } #[cfg(any(target_os = "linux", target_vendor = "apple"))] -const NORMAL_FMTSTR: &str = +const NORMAL_FORMAT_STR: &str = "%a %A %b %B %d %D %f %F %g %G %h %i %m %n %o %s %u %U %x %X %y %Y %z %Z"; // avoid "%w %W" (birth/creation) due to `stat` limitations and linux kernel & rust version capability variations #[cfg(any(target_os = "linux"))] -const DEV_FMTSTR: &str = +const DEV_FORMAT_STR: &str = "%a %A %b %B %d %D %f %F %g %G %h %i %m %n %o %s (%t/%T) %u %U %w %W %x %X %y %Y %z %Z"; #[cfg(target_os = "linux")] -const FS_FMTSTR: &str = "%b %c %i %l %n %s %S %t %T"; // avoid "%a %d %f" which can cause test failure due to race conditions +const FS_FORMAT_STR: &str = "%b %c %i %l %n %s %S %t %T"; // avoid "%a %d %f" which can cause test failure due to race conditions #[test] #[cfg(target_os = "linux")] @@ -118,7 +118,7 @@ fn test_terse_fs_format() { #[test] #[cfg(target_os = "linux")] fn test_fs_format() { - let args = ["-f", "-c", FS_FMTSTR, "/dev/shm"]; + let args = ["-f", "-c", FS_FORMAT_STR, "/dev/shm"]; new_ucmd!() .args(&args) .run() @@ -207,7 +207,7 @@ fn test_format_created_seconds() { #[cfg(any(target_os = "linux", target_vendor = "apple"))] #[test] fn test_normal_format() { - let args = ["-c", NORMAL_FMTSTR, "/bin"]; + let args = ["-c", NORMAL_FORMAT_STR, "/bin"]; new_ucmd!() .args(&args) .succeeds() @@ -231,14 +231,14 @@ fn test_symlinks() { ] { if at.file_exists(file) && at.is_symlink(file) { tested = true; - let args = ["-c", NORMAL_FMTSTR, file]; + let args = ["-c", NORMAL_FORMAT_STR, file]; scene .ucmd() .args(&args) .succeeds() .stdout_is(expected_result(&args)); // -L, --dereference follow links - let args = ["-L", "-c", NORMAL_FMTSTR, file]; + let args = ["-L", "-c", NORMAL_FORMAT_STR, file]; scene .ucmd() .args(&args) @@ -261,7 +261,7 @@ fn test_char() { let args = [ "-c", #[cfg(target_os = "linux")] - DEV_FMTSTR, + DEV_FORMAT_STR, #[cfg(target_os = "linux")] "/dev/pts/ptmx", #[cfg(any(target_vendor = "apple"))] @@ -280,7 +280,7 @@ fn test_char() { fn test_multi_files() { let args = [ "-c", - NORMAL_FMTSTR, + NORMAL_FORMAT_STR, "/dev", "/usr/lib", #[cfg(target_os = "linux")] diff --git a/tests/by-util/test_tail.rs b/tests/by-util/test_tail.rs index 737d0cabf..b31344c34 100644 --- a/tests/by-util/test_tail.rs +++ b/tests/by-util/test_tail.rs @@ -78,7 +78,7 @@ fn test_follow_multiple() { at.append(FOOBAR_2_TXT, first_append); assert_eq!(read_size(&mut child, first_append.len()), first_append); - let second_append = "doce\ntrece\n"; + let second_append = "twenty\nthirty\n"; let expected = at.read("foobar_follow_multiple_appended.expected"); at.append(FOOBAR_TXT, second_append); assert_eq!(read_size(&mut child, expected.len()), expected); @@ -95,7 +95,7 @@ fn test_follow_stdin() { .stdout_is_fixture("follow_stdin.expected"); } -// FixME: test PASSES for usual windows builds, but fails for coverage testing builds (likely related to the specific RUSTFLAGS '-Zpanic_abort_tests -Cpanic=abort') This test also breaks tty settings under bash requiring a 'stty sane' or reset. +// FixME: test PASSES for usual windows builds, but fails for coverage testing builds (likely related to the specific RUSTFLAGS '-Zpanic_abort_tests -Cpanic=abort') This test also breaks tty settings under bash requiring a 'stty sane' or reset. // spell-checker:disable-line #[cfg(disable_until_fixed)] #[test] fn test_follow_with_pid() { @@ -130,7 +130,7 @@ fn test_follow_with_pid() { at.append(FOOBAR_2_TXT, first_append); assert_eq!(read_size(&mut child, first_append.len()), first_append); - let second_append = "doce\ntrece\n"; + let second_append = "twenty\nthirty\n"; let expected = at.read("foobar_follow_multiple_appended.expected"); at.append(FOOBAR_TXT, second_append); assert_eq!(read_size(&mut child, expected.len()), expected); @@ -268,7 +268,7 @@ fn test_parse_size() { assert!(parse_size("1Y").is_err()); // Bad number - assert!(parse_size("328hdsf3290").is_err()); + assert!(parse_size("328hdsf3290").is_err()); // spell-checker:disable-line } #[test] diff --git a/tests/by-util/test_test.rs b/tests/by-util/test_test.rs index 3a55f772a..aaf09d657 100644 --- a/tests/by-util/test_test.rs +++ b/tests/by-util/test_test.rs @@ -8,6 +8,8 @@ // file that was distributed with this source code. // +// spell-checker:ignore (words) pseudofloat + use crate::common::util::*; #[test] @@ -73,13 +75,13 @@ fn test_negated_or() { } #[test] -fn test_strlen_of_nothing() { +fn test_string_length_of_nothing() { // odd but matches GNU, which must interpret -n as a literal here new_ucmd!().arg("-n").succeeds(); } #[test] -fn test_strlen_of_empty() { +fn test_string_length_of_empty() { new_ucmd!().args(&["-n", ""]).run().status_code(1); // STRING equivalent to -n STRING @@ -98,7 +100,7 @@ fn test_zero_len_of_empty() { } #[test] -fn test_solo_paren_is_literal() { +fn test_solo_parenthesis_is_literal() { let scenario = TestScenario::new(util_name!()); let tests = [["("], [")"]]; @@ -167,7 +169,7 @@ fn test_dangling_string_comparison_is_error() { } #[test] -fn test_stringop_is_literal_after_bang() { +fn test_string_operator_is_literal_after_bang() { let scenario = TestScenario::new(util_name!()); let tests = [ ["!", "="], @@ -208,7 +210,7 @@ fn test_pseudofloat_not_equal() { #[test] fn test_negative_arg_is_a_string() { new_ucmd!().arg("-12345").succeeds(); - new_ucmd!().arg("--qwert").succeeds(); + new_ucmd!().arg("--qwert").succeeds(); // spell-checker:disable-line } #[test] @@ -475,12 +477,12 @@ fn test_nonexistent_file_is_not_symlink() { } #[test] -fn test_op_prec_and_or_1() { +fn test_op_precedence_and_or_1() { new_ucmd!().args(&[" ", "-o", "", "-a", ""]).succeeds(); } #[test] -fn test_op_prec_and_or_1_overridden_by_parentheses() { +fn test_op_precedence_and_or_1_overridden_by_parentheses() { new_ucmd!() .args(&["(", " ", "-o", "", ")", "-a", ""]) .run() @@ -488,14 +490,14 @@ fn test_op_prec_and_or_1_overridden_by_parentheses() { } #[test] -fn test_op_prec_and_or_2() { +fn test_op_precedence_and_or_2() { new_ucmd!() .args(&["", "-a", "", "-o", " ", "-a", " "]) .succeeds(); } #[test] -fn test_op_prec_and_or_2_overridden_by_parentheses() { +fn test_op_precedence_and_or_2_overridden_by_parentheses() { new_ucmd!() .args(&["", "-a", "(", "", "-o", " ", ")", "-a", " "]) .run() @@ -529,7 +531,7 @@ fn test_negated_boolean_precedence() { } #[test] -fn test_bang_boolop_precedence() { +fn test_bang_bool_op_precedence() { // For a Boolean combination of two literals, bang inverts the entire expression new_ucmd!().args(&["!", "", "-a", ""]).succeeds(); new_ucmd!().args(&["!", "", "-o", ""]).succeeds(); @@ -564,7 +566,7 @@ fn test_bang_boolop_precedence() { } #[test] -fn test_inverted_parenthetical_boolop_precedence() { +fn test_inverted_parenthetical_bool_op_precedence() { // For a Boolean combination of two literals, bang inverts the entire expression new_ucmd!() .args(&["!", "a value", "-o", "another value"]) @@ -618,6 +620,6 @@ fn test_or_as_filename() { #[test] #[ignore = "GNU considers this an error"] -fn test_strlen_and_nothing() { +fn test_string_length_and_nothing() { new_ucmd!().args(&["-n", "a", "-a"]).run().status_code(2); } diff --git a/tests/by-util/test_timeout.rs b/tests/by-util/test_timeout.rs index 592516cca..28273e00f 100644 --- a/tests/by-util/test_timeout.rs +++ b/tests/by-util/test_timeout.rs @@ -4,7 +4,7 @@ use crate::common::util::*; // the best solution is probably to generate some test binaries that we can call for any // utility that requires executing another program (kill, for instance) #[test] -fn test_subcommand_retcode() { +fn test_subcommand_return_code() { new_ucmd!().arg("1").arg("true").succeeds(); new_ucmd!().arg("1").arg("false").run().status_code(1); diff --git a/tests/by-util/test_touch.rs b/tests/by-util/test_touch.rs index ecd56ab71..3c803e1c6 100644 --- a/tests/by-util/test_touch.rs +++ b/tests/by-util/test_touch.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore (formats) cymdhm cymdhms mdhm mdhms ymdhm ymdhms + extern crate touch; use self::touch::filetime::{self, FileTime}; @@ -411,13 +413,13 @@ fn is_dst_switch_hour(ts: time::Timespec) -> bool { tm_after.tm_hour == tm.tm_hour + 2 } -// get_dstswitch_hour returns date string for which touch -m -t fails. +// get_dst_switch_hour returns date string for which touch -m -t fails. // For example, in EST (UTC-5), that will be "202003080200" so -// touch -m -t 202003080200 somefile +// touch -m -t 202003080200 file // fails (that date/time does not exist). // In other locales it will be a different date/time, and in some locales // it doesn't exist at all, in which case this function will return None. -fn get_dstswitch_hour() -> Option { +fn get_dst_switch_hour() -> Option { let now = time::now(); // Start from January 1, 2020, 00:00. let mut tm = time::strptime("20200101-0000", "%Y%m%d-%H%M").unwrap(); @@ -443,7 +445,7 @@ fn test_touch_mtime_dst_fails() { let (_at, mut ucmd) = at_and_ucmd!(); let file = "test_touch_set_mtime_dst_fails"; - if let Some(s) = get_dstswitch_hour() { + if let Some(s) = get_dst_switch_hour() { ucmd.args(&["-m", "-t", &s, file]).fails(); } } diff --git a/tests/by-util/test_tr.rs b/tests/by-util/test_tr.rs index 29712b44a..936af2ca8 100644 --- a/tests/by-util/test_tr.rs +++ b/tests/by-util/test_tr.rs @@ -1,7 +1,7 @@ use crate::common::util::*; #[test] -fn test_toupper() { +fn test_to_upper() { new_ucmd!() .args(&["a-z", "A-Z"]) .pipe_in("!abcd!") @@ -80,10 +80,10 @@ fn test_complement2() { #[test] fn test_complement3() { new_ucmd!() - .args(&["-c", "abcdefgh", "123"]) + .args(&["-c", "abcdefgh", "123"]) // spell-checker:disable-line .pipe_in("the cat and the bat") .run() - .stdout_is("3he3ca33a3d33he3ba3"); + .stdout_is("3he3ca33a3d33he3ba3"); // spell-checker:disable-line } #[test] @@ -140,9 +140,9 @@ fn test_translate_and_squeeze() { fn test_translate_and_squeeze_multiple_lines() { new_ucmd!() .args(&["-s", "x", "y"]) - .pipe_in("xxaax\nxaaxx") + .pipe_in("xxaax\nxaaxx") // spell-checker:disable-line .run() - .stdout_is("yaay\nyaay"); + .stdout_is("yaay\nyaay"); // spell-checker:disable-line } #[test] @@ -169,7 +169,7 @@ fn test_set1_longer_than_set2() { .args(&["abc", "xy"]) .pipe_in("abcde") .run() - .stdout_is("xyyde"); + .stdout_is("xyyde"); // spell-checker:disable-line } #[test] @@ -178,7 +178,7 @@ fn test_set1_shorter_than_set2() { .args(&["ab", "xyz"]) .pipe_in("abcde") .run() - .stdout_is("xycde"); + .stdout_is("xycde"); // spell-checker:disable-line } #[test] @@ -187,7 +187,7 @@ fn test_truncate() { .args(&["-t", "abc", "xy"]) .pipe_in("abcde") .run() - .stdout_is("xycde"); + .stdout_is("xycde"); // spell-checker:disable-line } #[test] @@ -196,7 +196,7 @@ fn test_truncate_with_set1_shorter_than_set2() { .args(&["-t", "ab", "xyz"]) .pipe_in("abcde") .run() - .stdout_is("xycde"); + .stdout_is("xycde"); // spell-checker:disable-line } #[test] @@ -216,8 +216,8 @@ fn missing_required_second_arg_fails() { #[test] fn test_interpret_backslash_escapes() { new_ucmd!() - .args(&["abfnrtv", r"\a\b\f\n\r\t\v"]) - .pipe_in("abfnrtv") + .args(&["abfnrtv", r"\a\b\f\n\r\t\v"]) // spell-checker:disable-line + .pipe_in("abfnrtv") // spell-checker:disable-line .succeeds() .stdout_is("\u{7}\u{8}\u{c}\n\r\t\u{b}"); } diff --git a/tests/by-util/test_truncate.rs b/tests/by-util/test_truncate.rs index a28ce9451..bb0f4a596 100644 --- a/tests/by-util/test_truncate.rs +++ b/tests/by-util/test_truncate.rs @@ -1,15 +1,15 @@ use crate::common::util::*; use std::io::{Seek, SeekFrom, Write}; -static TFILE1: &str = "truncate_test_1"; -static TFILE2: &str = "truncate_test_2"; +static FILE1: &str = "truncate_test_1"; +static FILE2: &str = "truncate_test_2"; #[test] fn test_increase_file_size() { let expected = 5 * 1024; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE1); - ucmd.args(&["-s", "+5K", TFILE1]).succeeds(); + let mut file = at.make_file(FILE1); + ucmd.args(&["-s", "+5K", FILE1]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); @@ -25,8 +25,8 @@ fn test_increase_file_size() { fn test_increase_file_size_kb() { let expected = 5 * 1000; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE1); - ucmd.args(&["-s", "+5KB", TFILE1]).succeeds(); + let mut file = at.make_file(FILE1); + ucmd.args(&["-s", "+5KB", FILE1]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); @@ -43,16 +43,11 @@ fn test_reference() { let expected = 5 * 1000; let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); - scene.ucmd().arg("-s").arg("+5KB").arg(TFILE1).run(); + scene.ucmd().arg("-s").arg("+5KB").arg(FILE1).run(); - scene - .ucmd() - .arg("--reference") - .arg(TFILE1) - .arg(TFILE2) - .run(); + scene.ucmd().arg("--reference").arg(FILE1).arg(FILE2).run(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); @@ -68,9 +63,9 @@ fn test_reference() { fn test_decrease_file_size() { let expected = 6; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); file.write_all(b"1234567890").unwrap(); - ucmd.args(&["--size=-4", TFILE2]).succeeds(); + ucmd.args(&["--size=-4", FILE2]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); assert!( @@ -85,9 +80,9 @@ fn test_decrease_file_size() { fn test_space_in_size() { let expected = 4; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); file.write_all(b"1234567890").unwrap(); - ucmd.args(&["--size", " 4", TFILE2]).succeeds(); + ucmd.args(&["--size", " 4", FILE2]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); assert!( @@ -106,22 +101,22 @@ fn test_failed() { #[test] fn test_failed_2() { let (_at, mut ucmd) = at_and_ucmd!(); - ucmd.args(&[TFILE1]).fails(); + ucmd.args(&[FILE1]).fails(); } #[test] fn test_failed_incorrect_arg() { let (_at, mut ucmd) = at_and_ucmd!(); - ucmd.args(&["-s", "+5A", TFILE1]).fails(); + ucmd.args(&["-s", "+5A", FILE1]).fails(); } #[test] fn test_at_most_shrinks() { let expected = 4; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); file.write_all(b"1234567890").unwrap(); - ucmd.args(&["--size", "<4", TFILE2]).succeeds(); + ucmd.args(&["--size", "<4", FILE2]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); assert!( @@ -136,9 +131,9 @@ fn test_at_most_shrinks() { fn test_at_most_no_change() { let expected = 10; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); file.write_all(b"1234567890").unwrap(); - ucmd.args(&["--size", "<40", TFILE2]).succeeds(); + ucmd.args(&["--size", "<40", FILE2]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); assert!( @@ -153,9 +148,9 @@ fn test_at_most_no_change() { fn test_at_least_grows() { let expected = 15; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); file.write_all(b"1234567890").unwrap(); - ucmd.args(&["--size", ">15", TFILE2]).succeeds(); + ucmd.args(&["--size", ">15", FILE2]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); assert!( @@ -170,9 +165,9 @@ fn test_at_least_grows() { fn test_at_least_no_change() { let expected = 10; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); file.write_all(b"1234567890").unwrap(); - ucmd.args(&["--size", ">4", TFILE2]).succeeds(); + ucmd.args(&["--size", ">4", FILE2]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); assert!( @@ -187,9 +182,9 @@ fn test_at_least_no_change() { fn test_round_down() { let expected = 8; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); file.write_all(b"1234567890").unwrap(); - ucmd.args(&["--size", "/4", TFILE2]).succeeds(); + ucmd.args(&["--size", "/4", FILE2]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); assert!( @@ -204,9 +199,9 @@ fn test_round_down() { fn test_round_up() { let expected = 12; let (at, mut ucmd) = at_and_ucmd!(); - let mut file = at.make_file(TFILE2); + let mut file = at.make_file(FILE2); file.write_all(b"1234567890").unwrap(); - ucmd.args(&["--size", "%4", TFILE2]).succeeds(); + ucmd.args(&["--size", "%4", FILE2]).succeeds(); file.seek(SeekFrom::End(0)).unwrap(); let actual = file.seek(SeekFrom::Current(0)).unwrap(); assert!( @@ -221,10 +216,10 @@ fn test_round_up() { fn test_size_and_reference() { let expected = 15; let (at, mut ucmd) = at_and_ucmd!(); - let mut file1 = at.make_file(TFILE1); - let mut file2 = at.make_file(TFILE2); + let mut file1 = at.make_file(FILE1); + let mut file2 = at.make_file(FILE2); file1.write_all(b"1234567890").unwrap(); - ucmd.args(&["--reference", TFILE1, "--size", "+5", TFILE2]) + ucmd.args(&["--reference", FILE1, "--size", "+5", FILE2]) .succeeds(); file2.seek(SeekFrom::End(0)).unwrap(); let actual = file2.seek(SeekFrom::Current(0)).unwrap(); diff --git a/tests/by-util/test_uname.rs b/tests/by-util/test_uname.rs index d878ed7ac..de3f42a6b 100644 --- a/tests/by-util/test_uname.rs +++ b/tests/by-util/test_uname.rs @@ -17,7 +17,7 @@ fn test_uname_processor() { } #[test] -fn test_uname_hwplatform() { +fn test_uname_hardware_platform() { let result = new_ucmd!().arg("-i").succeeds(); assert_eq!(result.stdout_str().trim_end(), "unknown"); } diff --git a/tests/by-util/test_unexpand.rs b/tests/by-util/test_unexpand.rs index e8b880287..692599361 100644 --- a/tests/by-util/test_unexpand.rs +++ b/tests/by-util/test_unexpand.rs @@ -38,7 +38,7 @@ fn unexpand_init_list_1() { } #[test] -fn unexpand_aflag_0() { +fn unexpand_flag_a_0() { new_ucmd!() .args(&["--"]) .pipe_in("e E\nf F\ng G\nh H\n") @@ -47,7 +47,7 @@ fn unexpand_aflag_0() { } #[test] -fn unexpand_aflag_1() { +fn unexpand_flag_a_1() { new_ucmd!() .args(&["-a"]) .pipe_in("e E\nf F\ng G\nh H\n") @@ -56,7 +56,7 @@ fn unexpand_aflag_1() { } #[test] -fn unexpand_aflag_2() { +fn unexpand_flag_a_2() { new_ucmd!() .args(&["-t8"]) .pipe_in("e E\nf F\ng G\nh H\n") diff --git a/tests/by-util/test_uptime.rs b/tests/by-util/test_uptime.rs index d20ad90c9..4dc90eb31 100644 --- a/tests/by-util/test_uptime.rs +++ b/tests/by-util/test_uptime.rs @@ -22,5 +22,5 @@ fn test_uptime_since() { #[test] fn test_failed() { - new_ucmd!().arg("willfail").fails(); + new_ucmd!().arg("will-fail").fails(); } diff --git a/tests/by-util/test_users.rs b/tests/by-util/test_users.rs index 89c3fdd0f..8ceb0eeb8 100644 --- a/tests/by-util/test_users.rs +++ b/tests/by-util/test_users.rs @@ -1,7 +1,7 @@ use crate::common::util::*; #[test] -fn test_users_noarg() { +fn test_users_no_arg() { new_ucmd!().succeeds(); } diff --git a/tests/by-util/test_wc.rs b/tests/by-util/test_wc.rs index 1203c0b1d..88c65c997 100644 --- a/tests/by-util/test_wc.rs +++ b/tests/by-util/test_wc.rs @@ -1,5 +1,7 @@ use crate::common::util::*; +// spell-checker:ignore (flags) lwmcL clmwL ; (path) bogusfile emptyfile manyemptylines moby notrailingnewline onelongemptyline onelongword + #[test] fn test_count_bytes_large_stdin() { for &n in &[ diff --git a/tests/by-util/test_who.rs b/tests/by-util/test_who.rs index 333b03f5b..16444b0cb 100644 --- a/tests/by-util/test_who.rs +++ b/tests/by-util/test_who.rs @@ -1,5 +1,7 @@ use crate::common::util::*; +// spell-checker:ignore (flags) runlevel mesg + #[cfg(any(target_vendor = "apple", target_os = "linux"))] #[test] fn test_count() { diff --git a/tests/common/util.rs b/tests/common/util.rs index 9ce7f0537..cd2633f0d 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -632,7 +632,7 @@ impl TestScenario { let tmpd = Rc::new(TempDir::new().unwrap()); let ts = TestScenario { bin_path: { - // Instead of hardcoding the path relative to the current + // Instead of hard coding the path relative to the current // directory, use Cargo's OUT_DIR to find path to executable. // This allows tests to be run using profiles other than debug. let target_dir = path_concat!(env!("OUT_DIR"), "..", "..", "..", PROGNAME); @@ -722,9 +722,10 @@ impl UCommand { cmd.current_dir(curdir.as_ref()); if env_clear { if cfg!(windows) { + // spell-checker:ignore (dll) rsaenh // %SYSTEMROOT% is required on Windows to initialize crypto provider // ... and crypto provider is required for std::rand - // From procmon: RegQueryValue HKLM\SOFTWARE\Microsoft\Cryptography\Defaults\Provider\Microsoft Strong Cryptographic Provider\Image Path + // From `procmon`: RegQueryValue HKLM\SOFTWARE\Microsoft\Cryptography\Defaults\Provider\Microsoft Strong Cryptographic Provider\Image Path // SUCCESS Type: REG_SZ, Length: 66, Data: %SystemRoot%\system32\rsaenh.dll" for (key, _) in env::vars_os() { if key.as_os_str() != "SYSTEMROOT" { @@ -802,7 +803,7 @@ impl UCommand { self } - /// provides stdinput to feed in to the command when spawned + /// provides standard input to feed in to the command when spawned pub fn pipe_in>>(&mut self, input: T) -> &mut UCommand { if self.bytes_into_stdin.is_some() { panic!("{}", MULTIPLE_STDIN_MEANINGLESS); @@ -934,6 +935,7 @@ pub fn vec_of_size(n: usize) -> Vec { /// Sanity checks for test utils #[cfg(test)] mod tests { + // spell-checker:ignore (tests) asdfsadfa use super::*; #[test] @@ -1012,7 +1014,7 @@ mod tests { } #[test] - fn test_no_std_errout() { + fn test_no_stderr_output() { let res = CmdResult { tmpd: None, code: None, diff --git a/tests/fixtures/cat/three_directories_and_file_and_stdin.stderr.expected b/tests/fixtures/cat/three_directories_and_file_and_stdin.stderr.expected index 1a8a33d77..04a2d4be8 100644 --- a/tests/fixtures/cat/three_directories_and_file_and_stdin.stderr.expected +++ b/tests/fixtures/cat/three_directories_and_file_and_stdin.stderr.expected @@ -1,5 +1,5 @@ cat: test_directory3/test_directory4: Is a directory -cat: filewhichdoesnotexist.txt: No such file or directory (os error 2) +cat: file_which_does_not_exist.txt: No such file or directory (os error 2) cat: test_directory3/test_directory5: Is a directory cat: test_directory3/../test_directory3/test_directory5: Is a directory cat: test_directory3: Is a directory diff --git a/tests/fixtures/ptx/gnu_ext_disabled_roff_auto_ref.expected b/tests/fixtures/ptx/gnu_ext_disabled_rightward_auto_ref.expected similarity index 100% rename from tests/fixtures/ptx/gnu_ext_disabled_roff_auto_ref.expected rename to tests/fixtures/ptx/gnu_ext_disabled_rightward_auto_ref.expected diff --git a/tests/fixtures/ptx/gnu_ext_disabled_roff_input_ref.expected b/tests/fixtures/ptx/gnu_ext_disabled_rightward_input_ref.expected similarity index 100% rename from tests/fixtures/ptx/gnu_ext_disabled_roff_input_ref.expected rename to tests/fixtures/ptx/gnu_ext_disabled_rightward_input_ref.expected diff --git a/tests/fixtures/ptx/gnu_ext_disabled_roff_no_ref.expected b/tests/fixtures/ptx/gnu_ext_disabled_rightward_no_ref.expected similarity index 100% rename from tests/fixtures/ptx/gnu_ext_disabled_roff_no_ref.expected rename to tests/fixtures/ptx/gnu_ext_disabled_rightward_no_ref.expected diff --git a/tests/fixtures/ptx/gnu_ext_disabled_roff_no_ref_word_regexp_exc_space.expected b/tests/fixtures/ptx/gnu_ext_disabled_rightward_no_ref_word_regexp_exc_space.expected similarity index 100% rename from tests/fixtures/ptx/gnu_ext_disabled_roff_no_ref_word_regexp_exc_space.expected rename to tests/fixtures/ptx/gnu_ext_disabled_rightward_no_ref_word_regexp_exc_space.expected diff --git a/tests/fixtures/tail/foobar_follow_multiple_appended.expected b/tests/fixtures/tail/foobar_follow_multiple_appended.expected index 0896d3743..891eb6920 100644 --- a/tests/fixtures/tail/foobar_follow_multiple_appended.expected +++ b/tests/fixtures/tail/foobar_follow_multiple_appended.expected @@ -1,4 +1,4 @@ ==> foobar.txt <== -doce -trece +twenty +thirty diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 9d73450f6..64329bd0c 100644 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -1,4 +1,7 @@ #!/bin/bash + +# spell-checker:ignore (paths) abmon deref discrim getlimits getopt ginstall gnulib inacc infloop inotify reflink ; (misc) INT_OFLOW OFLOW ; (vars/env) BUILDDIR SRCDIR + set -e if test ! -d ../gnu; then echo "Could not find ../gnu" @@ -96,4 +99,3 @@ sed -i 's|seq \$|/usr/bin/timeout 0.1 seq \$|' tests/misc/seq-precision.sh tests sed -i 's|cat |/usr/bin/timeout 0.1 cat |' tests/misc/cat-self.sh test -f "${BUILDDIR}/getlimits" || cp src/getlimits "${BUILDDIR}" - diff --git a/util/rewrite_rules.rs b/util/rewrite_rules.rs index 8b29bbe92..3d680e24c 100644 --- a/util/rewrite_rules.rs +++ b/util/rewrite_rules.rs @@ -1,4 +1,4 @@ -//! Rules to update the codebase using Rerast +//! Rules to update the codebase using `rerast` /// Converts try!() to ? fn try_to_question_mark>(r: Result) -> Result { diff --git a/util/run-gnu-test.sh b/util/run-gnu-test.sh index b9948ccd3..61034e015 100644 --- a/util/run-gnu-test.sh +++ b/util/run-gnu-test.sh @@ -1,4 +1,5 @@ #!/bin/bash +# spell-checker:ignore (env/vars) BUILDDIR GNULIB SUBDIRS set -e BUILDDIR="${PWD}/uutils/target/release" GNULIB_DIR="${PWD}/gnulib" diff --git a/util/update-version.sh b/util/update-version.sh index 042d43b71..c71467fc4 100644 --- a/util/update-version.sh +++ b/util/update-version.sh @@ -14,7 +14,7 @@ PROGS=$(ls -1d src/uu/*/Cargo.toml src/uu/stdbuf/src/libstdbuf/Cargo.toml Cargo. # update the version of all programs sed -i -e "s|version = \"$FROM\"|version = \"$TO\"|" $PROGS -# Update the stbuff stuff +# Update the stdbuf stuff sed -i -e "s|libstdbuf = { version=\"$FROM\"|libstdbuf = { version=\"$TO\"|" src/uu/stdbuf/Cargo.toml sed -i -e "s|= { optional=true, version=\"$FROM\", package=\"uu_|= { optional=true, version=\"$TO\", package=\"uu_|g" Cargo.toml @@ -22,5 +22,3 @@ sed -i -e "s|= { optional=true, version=\"$FROM\", package=\"uu_|= { optional=tr #sed -i -e "s|version = \"$UUCORE_FROM\"|version = \"$UUCORE_TO\"|" src/uucore/Cargo.toml # Update crates using uucore #sed -i -e "s|uucore = { version=\">=$UUCORE_FROM\",|uucore = { version=\">=$UUCORE_TO\",|" $PROGS - -