All Projects β†’ stepchowfun β†’ tagref

stepchowfun / tagref

Licence: other
Tagref helps you maintain cross-references in your code.

Programming Languages

rust
11053 projects
shell
77523 projects

Projects that are alternatives of or similar to tagref

linter-alex
πŸ“Sensitive, considerate writing before you merge your Pull Requests
Stars: ✭ 67 (-27.17%)
Mutual labels:  continuous-integration, linter
arduino-lint
Tool to check for problems with Arduino projects
Stars: ✭ 63 (-31.52%)
Mutual labels:  continuous-integration, linter
makefiles
No description or website provided.
Stars: ✭ 23 (-75%)
Mutual labels:  continuous-integration, linter
arduino-lint-action
GitHub Actions action to check Arduino projects for problems
Stars: ✭ 20 (-78.26%)
Mutual labels:  continuous-integration, linter
Gopherci
GopherCI was a project to help you maintain high-quality Go projects, by checking each GitHub Pull Request, for backward incompatible changes, and a suite of other third party static analysis tools.
Stars: ✭ 105 (+14.13%)
Mutual labels:  continuous-integration, linter
typo3-typoscript-lint
Find coding errors in your TypoScript files.
Stars: ✭ 78 (-15.22%)
Mutual labels:  continuous-integration, linter
branch-name-lint
Lint your branch names
Stars: ✭ 60 (-34.78%)
Mutual labels:  continuous-integration, linter
Format.cmake
πŸ’… Stylize your code! Automatic clang-format and cmake-format targets for CMake.
Stars: ✭ 94 (+2.17%)
Mutual labels:  continuous-integration, linter
Android-CICD
This repo demonstrates how to work on CI/CD for Mobile Apps πŸ“± using Github Actions πŸ’Š + Firebase Distribution πŸŽ‰
Stars: ✭ 37 (-59.78%)
Mutual labels:  continuous-integration, linter
Flint
Fast and configurable filesystem (file and directory names) linter
Stars: ✭ 115 (+25%)
Mutual labels:  continuous-integration, linter
prlint
GitHub App for linting pull request meta data
Stars: ✭ 122 (+32.61%)
Mutual labels:  continuous-integration, linter
rubocop-graphql
Rubocop extension for enforcing graphql-ruby best practices
Stars: ✭ 143 (+55.43%)
Mutual labels:  linter
escape-inventory
Storing and querying Escape releases
Stars: ✭ 16 (-82.61%)
Mutual labels:  continuous-integration
marvel-jarvig
Marvel JARVIG (Just A Rather Very Interesting Game) is a game that lets you find and discover Marvel Comics characters based on their name, image and description!
Stars: ✭ 13 (-85.87%)
Mutual labels:  continuous-integration
dashinator
Dashinator the daringly delightful dashboard. A replacement for dashing
Stars: ✭ 56 (-39.13%)
Mutual labels:  continuous-integration
eslint-config
πŸš€ Jetrockets Standarts | ESLint
Stars: ✭ 20 (-78.26%)
Mutual labels:  linter
asterisklint
Asterisk PBX configuration syntax checker
Stars: ✭ 45 (-51.09%)
Mutual labels:  linter
showyourwork
Fully reproducible, open source scientific articles in LaTeX.
Stars: ✭ 361 (+292.39%)
Mutual labels:  continuous-integration
reuse-action
A Github action to check repositories for REUSE compliance
Stars: ✭ 31 (-66.3%)
Mutual labels:  linter
vscode-write-good
Write Good Linter for Visual Studio Code
Stars: ✭ 58 (-36.96%)
Mutual labels:  linter

Tagref

Build status

Tagref helps you maintain cross-references in your code. You can use it to help keep things in sync, document assumptions, manage invariants, etc. Airbnb uses it for their front-end monorepo. You should use it too!

Tagref works with any programming language, and it respects your .gitignore file as well as other common filter files. It's recommended to set up Tagref as an automated continuous integration (CI) check. Tagref is blazing fast (as they say) and almost certainly won't be the bottleneck in your CI.

What is it?

When writing code, it's common to refer to other parts of the codebase in comments. The traditional way to do that is to provide a file path and a line number. For example:

# Keep this in sync with controllers/profile.py:304.

Unfortunately, as we all know, this is brittle:

  1. As the code evolves, the line numbers may shift.
  2. The file might be renamed or deleted.

One strategy is to reference a specific commit. At least then you know the reader will be able to find the line that you're referencing:

# Keep this in sync with controllers/profile.py@55217c6:304.

But that approach isn't ideal, since the current version of the code may have diverged from the referenced commit in non-trivial ways.

Tagref solves this problem in a better way. It allows you to annotate your code with tags (in comments), which can be referenced from other parts of the codebase. For example, you might have a tag like this:

# [tag:cities_nonempty] This function always returns a non-empty list.
def get_cities():
  return ['San Francisco', 'Tokyo']

Elsewhere, suppose you're writing some code which depends on that postcondition. You can make that clear by referencing the tag:

cities = get_cities()

first_city = cities[0] # This is safe due to [ref:cities_nonempty].

Tagref ensures such references remain valid. If someone tries to delete or rename the tag, Tagref will complain. More precisely, it checks the following:

  1. References actually point to tags. A tag cannot be deleted or renamed without updating the references that point to it.
  2. Tags are unique. There is never any ambiguity about which tag is being referenced.

Note that, in the example above, Tagref won't ensure that the get_cities function actually returns a non-empty list. It isn't magic! It only checks the two conditions above.

Usage

The easiest way to use Tagref is to run the tagref command with no arguments. It will recursively scan the working directory and check the two conditions described above. Here are the supported command-line options:

USAGE:
    tagref [SUBCOMMAND]

OPTIONS:
    -h, --help
            Prints help information

    -p, --path <PATH>...
            Adds the path of a directory to scan [default: .]

    -r, --ref-prefix <REF_PREFIX>
            Sets the prefix used for locating references [default: ref]

    -t, --tag-prefix <TAG_PREFIX>
            Sets the prefix used for locating tags [default: tag]

    -v, --version
            Prints version information

SUBCOMMANDS:
    check
            Checks all the tags and references (default)

    help
            Prints this message or the help of the given subcommand(s)

    list-refs
            Lists all the references

    list-tags
            Lists all the tags

    list-unused
            Lists the unreferenced tags

Installation instructions

Installation on macOS or Linux (x86-64)

If you're running macOS or Linux on an x86-64 CPU, you can install Tagref with this command:

curl https://raw.githubusercontent.com/stepchowfun/tagref/main/install.sh -LSfs | sh

The same command can be used again to update to the latest version.

The installation script supports the following optional environment variables:

  • VERSION=x.y.z (defaults to the latest version)
  • PREFIX=/path/to/install (defaults to /usr/local/bin)

For example, the following will install Tagref into the working directory:

curl https://raw.githubusercontent.com/stepchowfun/tagref/main/install.sh -LSfs | PREFIX=. sh

If you prefer not to use this installation method, you can download the binary from the releases page, make it executable (e.g., with chmod), and place it in some directory in your PATH (e.g., /usr/local/bin).

Installation on Windows (x86-64)

If you're running Windows on an x86-64 CPU, download the latest binary from the releases page and rename it to tagref (or tagref.exe if you have file extensions visible). Create a directory called Tagref in your %PROGRAMFILES% directory (e.g., C:\Program Files\Tagref), and place the renamed binary in there. Then, in the "Advanced" tab of the "System Properties" section of Control Panel, click on "Environment Variables..." and add the full path to the new Tagref directory to the PATH variable under "System variables". Note that the Program Files directory might have a different name if Windows is configured for a language other than English.

To update to an existing installation, simply replace the existing binary.

Installation with Homebrew

If you have Homebrew, you can install Tagref as follows:

brew install tagref

You can update an existing installation with brew upgrade tagref.

Installation with Cargo

If you have Cargo, you can install Tagref as follows:

cargo install tagref

You can run that command with --force to update an existing installation.

Acknowledgements

The idea for Tagref was inspired by the GHC notes convention. This article has more insights into how the GHC developers manage their codebase.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].