blockwatch 0.1.0

Linter that tracks changes between dependent blocks of code
blockwatch-0.1.0 is not a library.
Visit the last successful build: blockwatch-0.2.25

blockwatch

Linter that tracks changes between dependent blocks of code.

How

Declare the blocks in the comments of the source file.

Validate by running git diff --patch | blockwatch:

Example

Whenever some block is modified then all its affected blocks (possibly in different files) should also be updated.

main.rs:

// <block affects="README.md:supported-languages">
const SUPPORTED_LANGUAGES = ["rust", "java", "python"];
// </block>

README.md:

## Supported languages

[//]: # (<block name="supported-languages">)

- Java
- Rust

[//]: # (</block>)

If the block in main.rs is modified (e.g. added python to the list) then the following command will produce an error:

git diff --patch | blockwatch

Supported languages

  • Java
  • Markdown
  • Rust

More examples

Blocks may reference blocks in the same file

// <block name="foo" affects=":bar, :buzz">
fn main() {
    println!("Blocks can affect multiple other blocks in declared in the same file");
    println!("Just omit the file name in the 'affects' attribute");
}
// </block>

// <block name="bar">
// Some other piece of code.
// </block>

// <block name="buzz">
// One more.
// </block>

Blocks may reference each other

// <block name="foo" affects=":bar">
fn foo() {
    println!("Hello");
}
// </block>

// <block name="bar" affects=":foo">
fn bar() {
    println!("Hi!");
}
// </block>

Blocks can be nested

// <block name="entire-file">
fn foo() {
    println!("Hello");
}

// <block name="small-block">
fn bar() {
    println!("Hi!");
}
// </block>
// </block>

Known limitations

  • deleted blocks are ignored
  • blocks declared in unsupported languages are ignored
  • multiple blocks can't be declared in a single line: <block><block>will not work</block/</block>

Install

TODO

Contributing

Adding a language support

TODO

Run tests

cargo test