Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bash script to evaluate decision tables #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cli_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Example

```sh

jo numberCVEOpened=0 | ./run.sh yard-impl1/src/test/resources/flightscore/cve.yml

```

```

jo sonarCloudScore=99 | ./run.sh yard-impl1/src/test/resources/flightscore/sonarcloud.yml
```
13 changes: 13 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

if [ "$#" -ne 1 ]; then
echo "Usage: $0 <model_file>"
exit 1
fi

model_file=$1


# printf "Running model $1 with json: $2\n"

java -jar yard-impl1-cli/target/yard-impl1-cli-1.0-SNAPSHOT.jar "$model_file" <<< "$(cat -)"
21 changes: 21 additions & 0 deletions yard-impl1/src/test/resources/flightscore/cve.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
specVersion: alpha
kind: YaRD
name: 'CVEs'
inputs:
- name: 'numberCVEOpened'
type: integer
elements:
- name: 'CVEScore'
type: Decision
requirements: ['numberOfCVEOpened']
logic:
type: DecisionTable
inputs: ['numberCVEOpened']
rules:
- when: ['>=5']
then: 0 # Bronze
- when: ['>=2']
then: 50 # silver
- when: ['=0']
then: 100
---
21 changes: 21 additions & 0 deletions yard-impl1/src/test/resources/flightscore/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
specVersion: alpha
kind: YaRD
name: 'SonarCloud'
inputs:
- name: 'sonarCloudScore'
type: integer
elements:
- name: 'sonarCloudScoreScoreCard'
type: Decision
requirements: [ 'sonarCloudScore' ]
logic:
type: DecisionTable
inputs: [ 'sonarCloudScore' ]
rules:
- when: [ '>=100' ]
then: { score: 100, "explanation" : "Code is perfect" }
- when: [ '<80' ]
then: { score: 0, "explanation" : "Code is total waste" }
- when: [ '>=80' ]
then: { score: 50, "explanation" : "Code needs some work to do" }
---
Loading