Skip to content

Commit

Permalink
added licence and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ismailbayram committed Jul 29, 2023
1 parent b1fc988 commit cda00e2
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 3 deletions.
1 change: 1 addition & 0 deletions .bigpicture.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"port": 44525,
"ignore": [
"web"
],
Expand Down
19 changes: 19 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2023 ismail bayram

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
141 changes: 138 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,140 @@
`^*_test.go`
# BigPicture: Validate Architecture
**Do not tell the rules, define them.**

`test/*`
BigPicture is a tool to validate the architecture of project.
It can be used in Continuous Integration (CI) pipelines to validate the architecture of the project
like in the `.github/workflows/codequality.yml`.

`validators/*.go`

# Supported Languages
- Go
- Java (Under Development)
- Python (Under Development)
- C# (Under Development)
- JS (Under Development)

# Installation
## Install with Go
```bash
go install github.com/ismailbayram/[email protected]
```

# Usage
## Server
Runs a server on port 44525. Architecture of the project can be seen on the browser.
```bash
bigpicture server
```

## Validate
Validates the architecture of the project according to the rules defined in the `.bigpicture.json` file.
```bash
bigpicture validate
```

## .bigpicture.json File
`.bigpicture.json` file is used to define the rules. It should be in the root directory of the project.
```json
{
"port": 44525,
"ignore": [
"web"
],
"validators": [
...
]
}
```
**port**: Port number of the server. Default value is 44525.

**ignore**: Directories to ignore. Default value is empty. For instance in this project `web` directory includes
non-go files, thus it should be ignored.

**validators**: List of validators. Default value is empty. See [Validators](#validators) section for more information.

## Validators
### NoImportValidator
Checks if the package imports the given package.

**Example 1**:
For instance, in this project, `/internal/config` package can not import any other package.
```json
{
"type": "no_import",
"args": {
"from": "/internal/config",
"to": "*"
}
}
```
**Example 2**:
For instance, in this project, `/internal/validator` package can not import any package in the `/internal/browser` package.
```json
{
"type": "no_import",
"args": {
"from": "/internal/validator",
"to": "/internal/browser"
}
}
```

### LineCountValidator
Checks if the package has files which have more than the given number of lines.

**Example**:
For instance, in this project, `/internal/browser` package can not have files which have more than 100 lines.
```json
{
"type": "line_count",
"args": {
"module": "/internal/browser",
"max": 100,
"ignore": ["*_test.go", "test/*.go"]
}
}
```

### FunctionValidator
Checks if the package has functions which have more than the given number of lines.

**Example**:
For instance, in this project, `/internal/browser` package can not have functions which have more than 10 lines.
```json
{
"type": "function",
"args": {
"module": "/internal",
"max_line_count": 50,
"ignore": ["*_test.go", "test/*.go"]
}
}
```

### InstabilityValidator
Checks if the instability metric of a package according to its directory is more than the given number.

**Instability Calculation**:

Package A is imported by 3 packages and it imports 2 packages. Instability metric of the package A is
`2 / (2 + 3) = 0.4`.

**Example**:
For instance, in this project, `/internal/browser` package can not have instability metric more than 0.5.
```json
{
"type": "instability",
"args": {
"module": "/internal",
"max": 0.5
}
}
```



# Contribution
There are many ways in which you can participate in this project, for example:

- Implement a new validator in `/internal/validator` directory.
- Implement a new language support in `/internal/browser` directory.
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func main() {
if err := bp.Validate(); err != nil {
fmt.Println("validation failed")
fmt.Println(err)
os.Exit(1)
}
case "help":
printHelp()
Expand Down

0 comments on commit cda00e2

Please sign in to comment.