Skip to content

Commit

Permalink
Finish 1.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
amb1ent committed Jun 27, 2023
2 parents 9a7eb19 + 290e9d5 commit 44edb90
Show file tree
Hide file tree
Showing 13 changed files with 623 additions and 21 deletions.
59 changes: 54 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ err0 is an Error Code Management Platform.

The use of Error Codes enable to solve key scaling issues in Product Management, QA, User eXperience, Customer eXperience, DevOps and Monitoring, Logs Management, CyberSecurity, Compliance and audit trails, Support and Software debugging.

See https://www.err0.io/ for more information.
See <a href="https://bit.ly/3Sv4dLV">err0.io/</a> for more information, demo request, contact, and check our <a href="https://www.linkedin.com/company/err0-io/">LinkedIn</a> for more information on the power of error codes.

Please note that err0 is totally free for all Open-Source projects, just contact us.

## What is required to test or use err0?

Expand All @@ -44,6 +46,7 @@ The err0agent automatically detects the programming language.
<img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/python/python-original-wordmark.svg" width="50" height="50"/>
<img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/rust/rust-plain.svg" width="50" height="50"/>
<img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/go/go-original-wordmark.svg" width="50" height="50"/>
<img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/lua/lua-plain-wordmark.svg" width="50" />
</div>

## Can it be integrated in CI/CD?
Expand All @@ -55,21 +58,37 @@ Yes. We are using both GitLab and GitHub on our side, and the err0agent is provi
<img src="https://raw.githubusercontent.com/docker-library/docs/e2782b8942c1af41419536078c8d0176665a005d/maven/logo.png" width="120" height="50">
</div>

## Knowledge Base

err0 platform enables to publish and maintain Knowledge Data Bases (KDB) of error codes, thus bringing a key solution to major pain point.

Visit the err0agent knowledge base: <a href="http://bit.ly/3YYxmS5">err0 agent KDB</a> for more information on err0agent's codes.

## Quality Metrics

When running the err0agent it will collect metrics on errors and logs quality:

- Number of static messages (not parameter)
- Number of dynamic messages (with parameters)
- Number of duplicate messages (the same message used in multiple places)
- Number of messages per log level
- Average number of errors and logs per file

## Using err0agent

You will need Java version 1.8 or above.

### Stand-alone mode

In stand-alone mode, you can use the err0agent jar to manage error codes in your project!
In stand-alone mode, you can use the err0agent jar to insert error codes in your project! See the demo below, 2 minutes on freshly cloned from GitHub AI project coded in Python.

[![asciicast](https://asciinema.org/a/557983.svg)](https://asciinema.org/a/557983)
<a href="https://asciinema.org/a/557983" target="_blank"><img src="https://asciinema.org/a/557983.svg" /></a>

When you're ready to use this in production why not <a href="https://bit.ly/3PJoFaw">create an err0 account</a>, you can make a detailed configuration for the agent on our platform and of course manage knowledge around your error codes.
When you're ready to use this in production why not <a href="https://bit.ly/3Sv4dLV">create an err0 account</a>, you can make a detailed configuration for the agent on our platform and of course manage knowledge around your error codes. It's free, no credit card required.

### Full mode

A step by step guide is available on the <a href="https://bit.ly/3PJoFaw">err0</a> platform, which details each step:
A step by step guide is available on the <a href="https://bit.ly/3Sv4dLV">err0</a> platform, which details each step:
1. Create a numbering policy
2. Add a project to the numbering policy
3. Run the agent, in sandbox mode, on your code to insert error codes
Expand All @@ -81,6 +100,36 @@ A step by step guide is available on the <a href="https://bit.ly/3PJoFaw">err0</
9. Contribute knowledge and publish knowledge base on your error codes
10. Use error code contexts to keep track of how frequently error codes are occuring

<a href="https://asciinema.org/a/564800?t=02" target="_blank"><img src="https://asciinema.org/a/564800.svg" /></a>

### err0agent command line parameters help
```
usage: err0agent
-b,--branch <arg> Can be used to provide a branch name e.g. in a
CI/CD pipeline.
-c,--check Use err0agent to check for canonical codes in
your project.
-d,--dirty Can be used to run err0agent with a dirty
checkout.
-e,--error-codes Can be used to output error code data in json
format.
-g,--git-dir <arg> Use with this git project.
-h,--help Print this help message.
-i,--insert Use err0agent to insert codes in your project.
-m,--metrics Can be used to output source code metrics in json
format.
-r,--renumber When used with insert, will renumber the project.
-s,--stand-alone Run err0agent stand alone, no account required!
-t,--token-file <arg> Run err0agent with a project token (json) from
err0.io.
-v,--version Show the current version of err0agent.
You must specify:
1 of --stand-alone, or --token-file
1 of --insert, or --check
--git-dir
```

## License

[Apache 2.0 License](https://github.com/Err0-io/err0agent/LICENSE)
7 changes: 5 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ plugins {
}

group = "io.err0"
version = "1.3.3-BETA"
version = "1.3.4-BETA"

repositories {
mavenCentral()
Expand Down Expand Up @@ -120,6 +120,9 @@ tasks.withType<Test> {
}

tasks.withType<JavaExec> {
args = listOf(
"--token", "../open-source-bundle/dev-localhost/err0-smartthingsedgedrivers-20230603-077907dc-0214-11ee-a0ed-305a3ac84b71.json", "--insert", "../open-source-bundle/SmartThingsEdgeDrivers", // Lua
)
/*
// Check-out the open-source-bundle project at the same parent level as this project:
args = listOf(
Expand Down Expand Up @@ -167,5 +170,5 @@ tasks.withType<JavaExec> {
)
*/
args = listOf("--version", "--help")
//args = listOf("--version", "--help")
}
18 changes: 6 additions & 12 deletions src/main/java/io/err0/client/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ public static void scan(final ProjectPolicy projectPolicy, final GlobalState glo
final boolean pythonAllowed = codePolicy.mode != CodePolicy.CodePolicyMode.ADVANCED_CONFIGURATION || (null == codePolicy.adv_python || !codePolicy.adv_python.disable_language);
final boolean cCppAllowed = codePolicy.mode != CodePolicy.CodePolicyMode.ADVANCED_CONFIGURATION || (null == codePolicy.adv_ccpp || !codePolicy.adv_ccpp.disable_language);
final boolean rustAllowed = codePolicy.mode != CodePolicy.CodePolicyMode.ADVANCED_CONFIGURATION || (null == codePolicy.adv_rust || !codePolicy.adv_rust.disable_language);
final boolean luaAllowed = codePolicy.mode != CodePolicy.CodePolicyMode.ADVANCED_CONFIGURATION || (null == codePolicy.adv_lua || !codePolicy.adv_lua.disable_language);

try (Stream<Path> paths = Files.walk(Paths.get(startPoint)))
{
Expand Down Expand Up @@ -1060,13 +1061,18 @@ public static void scan(final ProjectPolicy projectPolicy, final GlobalState glo
final FileCoding fileCoding = new FileCoding(p);
globalState.store(newFile, localToCheckoutUnchanged, localToCheckoutLower, RustSourceCodeParse.lex(projectPolicy.getCodePolicy(), fileCoding.content), fileCoding.charset);
System.out.println("[AGENT-000072] Parsed: " + newFile);
} else if (luaAllowed && newFileLower.endsWith(".lua")) {
final FileCoding fileCoding = new FileCoding(p);
globalState.store(newFile, localToCheckoutUnchanged, localToCheckoutLower, LuaSourceCodeParse.lex(projectPolicy.getCodePolicy(), fileCoding.content), fileCoding.charset);
System.out.println("[AGENT-000094] Parsed: " + newFile);
}
}
});
}
catch (IOException e) {
System.err.println("[AGENT-000069] While recursing: " + startPoint);
e.printStackTrace(System.err);
System.exit(-1);
}

});
Expand Down Expand Up @@ -1214,9 +1220,6 @@ private static boolean analyseWholeProject(final ApiProvider apiProvider, final

if ((
parse.couldContainErrorNumber(currentToken)
//(sourceType != SourceCodeParse.ParseType.JAVASCRIPT && sourceType != SourceCodeParse.ParseType.GOLANG && sourceType != SourceCodeParse.ParseType.PHP && currentToken.type == ParseItem.QUOT_LITERAL) ||
//(sourceType == SourceCodeParse.ParseType.PHP && (currentToken.type == ParseItem.QUOT_LITERAL || currentToken.type == ParseItem.APOS_LITERAL)) ||
//((sourceType == SourceCodeParse.ParseType.JAVASCRIPT || sourceType == SourceCodeParse.ParseType.GOLANG) && (currentToken.type == ParseItem.QUOT_LITERAL || currentToken.type == ParseItem.APOS_LITERAL || currentToken.type == ParseItem.BACKTICK_LITERAL))
) &&
null != lastToken &&
lastToken.type == TokenClassification.SOURCE_CODE
Expand Down Expand Up @@ -1585,9 +1588,6 @@ public int compare(TokenStateItem o1, TokenStateItem o2) {
for (int i = 0, l = fileNamesInOrder.length; i < l; ++i) {
final String filename = fileNamesInOrder[i];

//if (! filename.endsWith("StreetStallWebVerticle.java")) continue;
//if (! filename.endsWith("PublishedSnapshotService.cs")) continue;

final StateItem stateItem = globalState.files.get(filename);
final SourceCodeParse parse = stateItem.parse;

Expand Down Expand Up @@ -1726,9 +1726,6 @@ public int compare(TokenStateItem o1, TokenStateItem o2) {
for (int i = 0, l = fileNamesInOrder.length; i < l; ++i) {
final String filename = fileNamesInOrder[i];

//if (! filename.endsWith("StreetStallWebVerticle.java")) continue;
//if (! filename.endsWith("PublishedSnapshotService.cs")) continue;

final StateItem stateItem = globalState.files.get(filename);
final SourceCodeParse parse = stateItem.parse;

Expand Down Expand Up @@ -1769,9 +1766,6 @@ public int compare(TokenStateItem o1, TokenStateItem o2) {
for (int i = 0, l = fileNamesInOrder.length; i < l; ++i) {
final String filename = fileNamesInOrder[i];

//if (! filename.endsWith("StreetStallWebVerticle.java")) continue;
//if (! filename.endsWith("PublishedSnapshotService.cs")) continue;

final StateItem stateItem = globalState.files.get(filename);
final SourceCodeParse parse = stateItem.parse;

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/io/err0/client/core/CodePolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public CodePolicy(final JsonObject codePolicyJson)
this.adv_ccpp = null == e ? new LanguageCodePolicy(new JsonObject()) : new LanguageCodePolicy(e.getAsJsonObject());
e = codePolicyJson.get("adv_rust");
this.adv_rust = null == e ? new LanguageCodePolicy(new JsonObject()) : new LanguageCodePolicy(e.getAsJsonObject());
e = codePolicyJson.get("adv_lua");
this.adv_lua = null == e ? new LanguageCodePolicy(new JsonObject()) : new LanguageCodePolicy(e.getAsJsonObject());
break;
default:
throw new RuntimeException("[AGENT-000009] Unknown mode");
Expand All @@ -84,6 +86,7 @@ public CodePolicy(final JsonObject codePolicyJson)
public LanguageCodePolicy adv_ts;
public LanguageCodePolicy adv_ccpp;
public LanguageCodePolicy adv_rust;
public LanguageCodePolicy adv_lua;

public String easyModeObjectPattern() {
JsonElement el = codePolicyJson.get("easy_mode_logger_object_naming_pattern");
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/io/err0/client/core/ProjectPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,14 @@ public Pattern getReErrorNumber_py() {
return reErrorNumber_py;
}

private Pattern reErrorNumber_lua = null;
public Pattern getReErrorNumber_lua() {
if (null == reErrorNumber_lua) {
reErrorNumber_lua = Pattern.compile("^('|\"|(\\[=*\\[))\\[" + getErrorPrefix() + "-(\\d+)\\]\\s*");
}
return reErrorNumber_lua;
}

public CodePolicy getCodePolicy() {
if (null == this.prj_code_policy) {
return realmPolicy.realm_code_policy;
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/io/err0/client/core/SourceCodeParse.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@ public SourceCodeParse(final Language language, final CodePolicy policy, final L
public final LanguageCodePolicy languageCodePolicy;

public enum Language {
JAVA, C_SHARP, GOLANG, PYTHON, JAVASCRIPT, TYPESCRIPT, PHP, C_CPP, RUST
JAVA,
C_SHARP,
GOLANG,
PYTHON,
JAVASCRIPT,
TYPESCRIPT,
PHP,
C_CPP,
RUST,
LUA,
}

public final ArrayList<Token> tokenList = new ArrayList<>();
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/io/err0/client/core/Token.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public Token(final int n, final Token prev) {
public Token next() { return this.next; }

public TokenClassification type;
public int longBracketLevel = 0;
public StringBuilder sourceCode = new StringBuilder();
public String initialSource = null;
public String source = null;
Expand All @@ -62,6 +63,8 @@ public String getStringLiteral()
return s.length() > 6 ? s.substring(3, s.length() - 6) : "";
case BACKTICK_LITERAL:
return s.length() > 2 ? s.substring(1, s.length() - 2) : "";
case LONGBRACKET_LITERAL:
return s.length() > (4 + (2*longBracketLevel)) ? s.substring(2 + longBracketLevel, s.length() - (4 + (2*longBracketLevel))) : "";
default:
throw new RuntimeException("[AGENT-000020] Not a string literal, type = " + type.name());
}
Expand All @@ -76,6 +79,8 @@ public int getStringQuoteWidth()
return 1;
case QUOT3_LITERAL:
return 3;
case LONGBRACKET_LITERAL:
return 2 + longBracketLevel;
default:
throw new RuntimeException("[AGENT-000017] Not a string literal, type = " + type.name());
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/err0/client/core/TokenClassification.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ public enum TokenClassification {
APOS_LITERAL,
QUOT_LITERAL,
QUOT3_LITERAL,
BACKTICK_LITERAL
BACKTICK_LITERAL,
LONGBRACKET_LITERAL,
}
Loading

0 comments on commit 44edb90

Please sign in to comment.