Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ioncakephper/contract-shield-cli

Repository files navigation

contract-shield-cli

A CLI tool that verifies preconditions, postconditions, and invariants in contracts without altering their original source code. contract-shield-cli enforces Design by Contract principles externally, ensuring contracts behave as expected while preserving their integrity.

Features

  • Precondition Validation (@pre) – Ensures input conditions are met before execution.
  • Postcondition Verification (@post) – Confirms expected results after execution.
  • Invariant Checking (@invariant) – Maintains logical consistency across operations.
  • Source Code Integrity – Works externally without modifying the original code.

Installation

To install contract-shield-cli, use:

npm install -g contract-shield-cli

Example

Given the following contract source code:

/**
 * Example function with validation tags
 * @pre amount > 0
 * @post balance == previousBalance - amount
 * @post balance >= 0
 */
function withdraw(amount) {
}

The tool will generate a modified version of the contract that enforces these conditions

Contributing

  • Fork the repository.
  • Create a feature branch (git checkout -b feature-branch).
  • Commit changes (git commit -m "Add feature").
  • Push to GitHub (git push origin feature-branch).
  • Open a Pull Request.

License

This project is licensed under the MIT License. See LICENSE for details.

About

A CLI tool that processes @pre, @post, and @invariant tags in functions, classes, and methods within a source file. It generates a modified version of the source code that automatically validates input conditions (@pre), result conditions (@post), and invariant conditions (@invariant).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

AltStyle によって変換されたページ (->オリジナル) /