Skip to content

Commit 7d9359c

Browse files
committed
Fix clippy issues
1 parent 67d46fb commit 7d9359c

4 files changed

Lines changed: 23 additions & 22 deletions

File tree

src/bin/cli.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,7 @@ fn convert(args: ConvertArgs) -> Result<(), Box<dyn Error>> {
380380
Templates::Linkml => serialize_linkml(model, args.output.as_ref())?,
381381
Templates::Internal => render_internal_schema(&model)?,
382382
Templates::JsonLd => {
383-
let root = match args.root {
384-
Some(root) => Some(root),
385-
None => None,
386-
};
383+
let root = args.root;
387384
serde_json::to_string_pretty(&model.json_ld_header(root.as_deref())?).unwrap()
388385
}
389386
_ => render_jinja_template(&args.template, &mut model, Some(&config))?,

src/datamodel.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl DataModel {
321321
continue;
322322
}
323323
if let Some(duplicate_obj) = self.objects.iter().find(|o| o.name == other_obj.name) {
324-
if !duplicate_obj.same_hash(&other_obj) {
324+
if !duplicate_obj.same_hash(other_obj) {
325325
error!(
326326
"[{}] {}: Object {} is defined more than once.",
327327
"Merge".bold(),
@@ -338,7 +338,7 @@ impl DataModel {
338338
continue;
339339
}
340340
if let Some(duplicate_enm) = self.enums.iter().find(|e| e.name == other_enm.name) {
341-
if !duplicate_enm.same_hash(&other_enm) {
341+
if !duplicate_enm.same_hash(other_enm) {
342342
error!(
343343
"[{}] {}: Enumeration {} is defined more than once.",
344344
"Merge".bold(),

src/jsonld/export.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ fn build_detailed_term_def(
186186
) -> TermDef {
187187
// Determine type using the first dtype, falling back to parent_object if needed
188188
let object_type = attr
189-
.dtypes
190-
.get(0)
189+
.dtypes.first()
191190
.and_then(|dtype| find_sub_object(graph, dtype))
192191
.map(|_idx| "@id".to_string());
193192

src/jsonld/schema.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,31 +61,35 @@ impl JsonLdHeader {
6161
let import_url = import_url.into();
6262
match self.context.take() {
6363
None => {
64-
let mut obj = SimpleContext::default();
65-
obj.import = Some(import_url);
64+
let obj = SimpleContext {
65+
import: Some(import_url),
66+
..Default::default()
67+
};
6668
self.context = Some(JsonLdContext::Object(obj));
6769
}
6870
Some(JsonLdContext::Object(mut obj)) => {
6971
if obj.import.is_none() {
7072
obj.import = Some(import_url);
7173
self.context = Some(JsonLdContext::Object(obj));
7274
} else {
73-
let mut arr = Vec::new();
74-
arr.push(JsonLdContext::Object(obj));
75-
arr.push(JsonLdContext::Object(SimpleContext {
76-
import: Some(import_url),
77-
..Default::default()
78-
}));
75+
let arr = vec![
76+
JsonLdContext::Object(obj),
77+
JsonLdContext::Object(SimpleContext {
78+
import: Some(import_url),
79+
..Default::default()
80+
}),
81+
];
7982
self.context = Some(JsonLdContext::Array(arr));
8083
}
8184
}
8285
Some(JsonLdContext::Iri(iri)) => {
83-
let mut arr = Vec::new();
84-
arr.push(JsonLdContext::Iri(iri));
85-
arr.push(JsonLdContext::Object(SimpleContext {
86-
import: Some(import_url),
87-
..Default::default()
88-
}));
86+
let arr = vec![
87+
JsonLdContext::Iri(iri),
88+
JsonLdContext::Object(SimpleContext {
89+
import: Some(import_url),
90+
..Default::default()
91+
}),
92+
];
8993
self.context = Some(JsonLdContext::Array(arr));
9094
}
9195
Some(JsonLdContext::Array(mut arr)) => {
@@ -117,6 +121,7 @@ pub enum TypeOrVec {
117121
/// or combining several contexts in a single document.
118122
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
119123
#[serde(untagged)]
124+
#[allow(clippy::large_enum_variant)]
120125
pub enum JsonLdContext {
121126
/// The context is a remote document specified by an IRI.
122127
Iri(String),

0 commit comments

Comments
 (0)