fix: Clippy warnings (#424)

Also schedule works to be run at 8:00 AM everyday.

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2025-07-02 20:04:27 -05:00
committed by GitHub
parent 444b2970a1
commit 8ee1cf3298
20 changed files with 75 additions and 37 deletions

View File

@@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"
env:
CARGO_TERM_COLOR: always

View File

@@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"
env:
CARGO_TERM_COLOR: always

View File

@@ -16,6 +16,9 @@ on:
# The branches below must be a subset of the branches above
branches: [ "main" ]
workflow_dispatch:
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"
jobs:
rust-clippy-analyze:

View File

@@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"
jobs:
test:

View File

@@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"
jobs:
build-ffi:
@@ -129,4 +132,4 @@ jobs:
- name: Run Regorus.Tests
run: dotnet test --no-restore
working-directory: ./bindings/csharp/Regorus.Tests
working-directory: ./bindings/csharp/Regorus.Tests

View File

@@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"
jobs:
test:

View File

@@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"
jobs:
test:

View File

@@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"
jobs:
test:

View File

@@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"
env:
CARGO_TERM_COLOR: always

View File

@@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"
env:
CARGO_TERM_COLOR: always

View File

@@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"
env:
PYTHON_VERSION: "3.10"
@@ -86,4 +89,4 @@ jobs:
run: |
pip3 install ../../wheels/${{ matrix.host.wheel }}
python3 test.py
working-directory: bindings/python
working-directory: bindings/python

View File

@@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"
jobs:
test:

View File

@@ -5,6 +5,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Run at 8:00 AM every day
- cron: "0 8 * * *"
env:
CARGO_TERM_COLOR: always

View File

@@ -45,49 +45,49 @@ impl Engine {
self.engine
.borrow_mut()
.add_policy(path, rego)
.map_err(|e| Error::new(runtime_error(), format!("Failed to add policy: {}", e)))
.map_err(|e| Error::new(runtime_error(), format!("Failed to add policy: {e}")))
}
fn add_policy_from_file(&self, path: String) -> Result<String, Error> {
self.engine
.borrow_mut()
.add_policy_from_file(path)
.map_err(|e| Error::new(runtime_error(), format!("Failed to add policy: {}", e)))
.map_err(|e| Error::new(runtime_error(), format!("Failed to add policy: {e}")))
}
fn add_data(&self, ruby_hash: magnus::RHash) -> Result<(), Error> {
let data_value: regorus::Value = serde_magnus::deserialize(ruby_hash).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to deserialize Ruby value: {}", e),
format!("Failed to deserialize Ruby value: {e}"),
)
})?;
self.engine
.borrow_mut()
.add_data(data_value)
.map_err(|e| Error::new(runtime_error(), format!("Failed to add data: {}", e)))
.map_err(|e| Error::new(runtime_error(), format!("Failed to add data: {e}")))
}
fn add_data_json(&self, json_string: String) -> Result<(), Error> {
self.engine
.borrow_mut()
.add_data_json(&json_string)
.map_err(|e| Error::new(runtime_error(), format!("Failed to add data json: {}", e)))
.map_err(|e| Error::new(runtime_error(), format!("Failed to add data json: {e}")))
}
fn add_data_from_json_file(&self, path: String) -> Result<(), Error> {
let json_data = regorus::Value::from_json_file(path).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to parse JSON data file: {}", e),
format!("Failed to parse JSON data file: {e}"),
)
})?;
self.engine.borrow_mut().add_data(json_data).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to add data from file: {}", e),
format!("Failed to add data from file: {e}"),
)
})
}
@@ -115,7 +115,7 @@ impl Engine {
let input_value: regorus::Value = serde_magnus::deserialize(ruby_hash).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to deserialize Ruby value: {}", e),
format!("Failed to deserialize Ruby value: {e}"),
)
})?;
@@ -127,14 +127,14 @@ impl Engine {
self.engine
.borrow_mut()
.set_input_json(&json_string)
.map_err(|e| Error::new(runtime_error(), format!("Failed to set input JSON: {}", e)))
.map_err(|e| Error::new(runtime_error(), format!("Failed to set input JSON: {e}")))
}
fn add_input_from_json_file(&self, path: String) -> Result<(), Error> {
let json_data = regorus::Value::from_json_file(path).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to parse JSON input file: {}", e),
format!("Failed to parse JSON input file: {e}"),
)
})?;
@@ -147,12 +147,12 @@ impl Engine {
.engine
.borrow_mut()
.eval_query(query, false)
.map_err(|e| Error::new(runtime_error(), format!("Failed to evaluate query: {}", e)))?;
.map_err(|e| Error::new(runtime_error(), format!("Failed to evaluate query: {e}")))?;
serde_magnus::serialize(&results).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to serailzie query results: {}", e),
format!("Failed to serailzie query results: {e}"),
)
})
}
@@ -165,14 +165,14 @@ impl Engine {
.map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to evaluate query as json: {}", e),
format!("Failed to evaluate query as json: {e}"),
)
})?;
serde_json::to_string(&results).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to serialize query results: {}", e),
format!("Failed to serialize query results: {e}"),
)
})
}
@@ -180,7 +180,7 @@ impl Engine {
fn eval_rule(&self, query: String) -> Result<Option<magnus::Value>, Error> {
let result =
self.engine.borrow_mut().eval_rule(query).map_err(|e| {
Error::new(runtime_error(), format!("Failed to evaluate rule: {}", e))
Error::new(runtime_error(), format!("Failed to evaluate rule: {e}"))
})?;
match result {
@@ -190,7 +190,7 @@ impl Engine {
.map_err(|e| {
magnus::Error::new(
runtime_error(),
format!("Failed to serialize the rule evaluation result: {}", e),
format!("Failed to serialize the rule evaluation result: {e}"),
)
}),
}
@@ -200,7 +200,7 @@ impl Engine {
self.engine
.borrow_mut()
.eval_bool_query(query, false)
.map_err(|e| Error::new(runtime_error(), format!("Failed to evaluate query: {}", e)))
.map_err(|e| Error::new(runtime_error(), format!("Failed to evaluate query: {e}")))
}
fn eval_allow_query(&self, query: String) -> Result<bool, Error> {
@@ -226,14 +226,14 @@ impl Engine {
.map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to get coverage report as json: {}", e),
format!("Failed to get coverage report as json: {e}"),
)
})?;
serde_json::to_string(&report).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to serialize coverage report: {}", e),
format!("Failed to serialize coverage report: {e}"),
)
})
}
@@ -247,14 +247,14 @@ impl Engine {
.map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to get coverage report: {}", e),
format!("Failed to get coverage report: {e}"),
)
})?;
report.to_string_pretty().map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to convert report to colored string: {}", e),
format!("Failed to convert report to colored string: {e}"),
)
})
}
@@ -275,7 +275,7 @@ impl Engine {
self.engine.borrow_mut().take_prints().map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to gather print statement: {}", e),
format!("Failed to gather print statement: {e}"),
)
})
}

View File

@@ -23,7 +23,7 @@ fn main() -> Result<()> {
.output()
.expect("`git rev-parse HEAD` failed.");
let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
println!("cargo:rustc-env=GIT_HASH={git_hash}");
}
// Rerun only if build.rs changes.

View File

@@ -339,7 +339,7 @@ fn yaml_marshal(span: &Span, params: &[Ref<Expr>], args: &[Value], _strict: bool
ensure_args_count(span, name, params, args, 1)?;
let serialized = serde_yaml::to_string(&args[0])
.map_err(|err| span.error(&format!("could not serialize to yaml: {}", err)))?;
.map_err(|err| span.error(&format!("could not serialize to yaml: {err}")))?;
Ok(Value::String(serialized.into()))
}

View File

@@ -34,7 +34,7 @@ pub fn arithmetic_operation(
v2: Value,
strict: bool,
) -> Result<Value> {
let op_name = format!("{:?}", op).to_lowercase();
let op_name = format!("{op:?}").to_lowercase();
let v1 = ensure_numeric(op_name.as_str(), expr1, &v1)?;
let v2 = ensure_numeric(op_name.as_str(), expr2, &v2)?;

View File

@@ -440,7 +440,7 @@ fn json_match_schema(
// The following is expected to succeed.
let document: serde_json::Value = serde_json::from_str(&args[0].to_json_str()?)
.map_err(|err| span.error(&format!("Failed to parse JSON: {}", err)))?;
.map_err(|err| span.error(&format!("Failed to parse JSON: {err}")))?;
Ok(Value::from_array(
match compile_json_schema(&params[1], &args[1]) {

View File

@@ -733,7 +733,7 @@ impl Interpreter {
{
bail!(rhs
.span()
.error(&format!("redefinition for variable {}", name)));
.error(&format!("redefinition for variable {name}")));
}
(name, rhs_value)
@@ -3192,10 +3192,9 @@ impl Interpreter {
Expr::RefBrack { refr, index, .. } => (refr, Some(index.clone())),
Expr::RefDot { .. } => (refr, None),
Expr::Var { .. } => (refr, None),
_ => bail!(refr.span().error(&format!(
"invalid token {:?} with the default keyword",
refr
))),
_ => bail!(refr
.span()
.error(&format!("invalid token {refr:?} with the default keyword"))),
};
Parser::get_path_ref_components_into(refr, &mut path)?;

View File

@@ -403,13 +403,13 @@ impl Number {
pub fn format_bin(&self) -> String {
self.ensure_integer()
.map(|a| format!("{:b}", a))
.map(|a| format!("{a:b}"))
.unwrap_or("".to_string())
}
pub fn format_octal(&self) -> String {
self.ensure_integer()
.map(|a| format!("{:o}", a))
.map(|a| format!("{a:o}"))
.unwrap_or("".to_string())
}
@@ -469,13 +469,13 @@ impl Number {
pub fn format_hex(&self) -> String {
self.ensure_integer()
.map(|a| format!("{:x}", a))
.map(|a| format!("{a:x}"))
.unwrap_or("".to_string())
}
pub fn format_big_hex(&self) -> String {
self.ensure_integer()
.map(|a| format!("{:X}", a))
.map(|a| format!("{a:X}"))
.unwrap_or("".to_string())
}
}