Skip to content

Commit f759fef

Browse files
Aaron Elinejohn-h-kastner-aws
andcommitted
Addressing Comments
Co-authored-by: John Kastner <[email protected]> Signed-off-by: Aaron Eline <[email protected]>
1 parent 567eeba commit f759fef

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

cedar-policy-core/src/ast/entity.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,15 +355,16 @@ impl Entity {
355355
})
356356
}
357357

358-
/// Creates a new `Entity` with this UID, ancestors, and an empty set of attributes
358+
/// Create a new `Entity` with this UID, ancestors, and an empty set of attributes
359359
/// Since it lacks any attributes, this method returns `Self` instead of `Result<Self>`
360360
pub fn new_empty_attrs(
361361
uid: EntityUID,
362362
ancestors: HashSet<EntityUID>,
363363
extensions: &Extensions<'_>,
364364
) -> Self {
365-
// PANIC SAFETY
366-
// Safe as the hashmap is empty
365+
// Safe as the attributes hashmap is empty, and `Self::new`
366+
// can only error when evaluating an attribute expression
367+
// PANIC SAFETY (see above)
367368
#[allow(clippy::unwrap_used)]
368369
Self::new(uid, HashMap::new(), ancestors, extensions).unwrap()
369370
}

cedar-policy-core/src/entities.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ impl Entities {
164164
/// responsible for ensuring that TC and DAG hold before calling this method.
165165
///
166166
/// # Errors
167-
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entiites`
167+
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entities`
168168
/// - [`EntitiesError::TransitiveClosureError`] if `tc_computation ==
169169
/// TCComputation::EnforceAlreadyComputed` and the entities are not transitivly closed
170-
/// - [`EntitiesError::InvalidEntity` if `schema` is not none and any entities do not conform
170+
/// - [`EntitiesError::InvalidEntity`] if `schema` is not none and any entities do not conform
171171
/// to the schema
172172
pub fn from_entities(
173173
entities: impl IntoIterator<Item = Entity>,
@@ -824,7 +824,7 @@ mod json_parsing_tests {
824824
parser.from_json_value(json).expect("JSON is correct")
825825
}
826826

827-
/// Ensure the initial conditions of the entiites still hold
827+
/// Ensure the initial conditions of the entities still hold
828828
fn simple_entities_still_sane(e: &Entities) {
829829
let bob = r#"Test::"bob""#.parse().unwrap();
830830
let alice = e.entity(&r#"Test::"alice""#.parse().unwrap()).unwrap();

cedar-policy/src/api.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ impl Entities {
357357
/// integer), or if required attributes are missing or superfluous
358358
/// attributes are provided.
359359
/// # Errors
360-
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entiites`
361-
/// - [`EntitiesError::InvalidEntity` if `schema` is not none and any entities do not conform
360+
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entities`
361+
/// - [`EntitiesError::InvalidEntity`] if `schema` is not none and any entities do not conform
362362
/// to the schema
363363
pub fn from_entities(
364364
entities: impl IntoIterator<Item = Entity>,
@@ -387,8 +387,8 @@ impl Entities {
387387
/// Re-computing the transitive closure can be expensive, so it is advised
388388
/// to not call this method in a loop.
389389
/// # Errors
390-
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entiites`
391-
/// - [`EntitiesError::InvalidEntity` if `schema` is not none and any entities do not conform
390+
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entities`
391+
/// - [`EntitiesError::InvalidEntity`] if `schema` is not none and any entities do not conform
392392
/// to the schema
393393
pub fn add_entities(
394394
self,
@@ -421,8 +421,8 @@ impl Entities {
421421
/// Re-computing the transitive closure can be expensive, so it is advised
422422
/// to not call this method in a loop.
423423
/// # Errors
424-
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entiites`
425-
/// - [`EntitiesError::InvalidEntity` if `schema` is not none and any entities do not conform
424+
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entities`
425+
/// - [`EntitiesError::InvalidEntity`] if `schema` is not none and any entities do not conform
426426
/// to the schema
427427
/// - [`EntitiesError::Deserialization`] if there are errors while parsing the json
428428
pub fn add_entities_from_json_str(
@@ -459,8 +459,8 @@ impl Entities {
459459
/// Re-computing the transitive closure can be expensive, so it is advised
460460
/// to not call this method in a loop.
461461
/// # Errors
462-
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entiites`
463-
/// - [`EntitiesError::InvalidEntity` if `schema` is not none and any entities do not conform
462+
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entities`
463+
/// - [`EntitiesError::InvalidEntity`] if `schema` is not none and any entities do not conform
464464
/// to the schema
465465
/// - [`EntitiesError::Deserialization`] if there are errors while parsing the json
466466
pub fn add_entities_from_json_value(
@@ -498,8 +498,8 @@ impl Entities {
498498
/// to not call this method in a loop.
499499
///
500500
/// # Errors
501-
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entiites`
502-
/// - [`EntitiesError::InvalidEntity` if `schema` is not none and any entities do not conform
501+
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entities`
502+
/// - [`EntitiesError::InvalidEntity`] if `schema` is not none and any entities do not conform
503503
/// to the schema
504504
/// - [`EntitiesError::Deserialization`] if there are errors while parsing the json
505505
pub fn add_entities_from_json_file(
@@ -540,8 +540,8 @@ impl Entities {
540540
/// superfluous attributes are provided.
541541
///
542542
/// # Errors
543-
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entiites`
544-
/// - [`EntitiesError::InvalidEntity` if `schema` is not none and any entities do not conform
543+
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entities`
544+
/// - [`EntitiesError::InvalidEntity`] if `schema` is not none and any entities do not conform
545545
/// to the schema
546546
/// - [`EntitiesError::Deserialization`] if there are errors while parsing the json
547547
///
@@ -601,8 +601,8 @@ impl Entities {
601601
/// superfluous attributes are provided.
602602
///
603603
/// # Errors
604-
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entiites`
605-
/// - [`EntitiesError::InvalidEntity` if `schema` is not none and any entities do not conform
604+
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entities`
605+
/// - [`EntitiesError::InvalidEntity`]if `schema` is not none and any entities do not conform
606606
/// to the schema
607607
/// - [`EntitiesError::Deserialization`] if there are errors while parsing the json
608608
///
@@ -659,8 +659,8 @@ impl Entities {
659659
/// superfluous attributes are provided.
660660
///
661661
/// # Errors
662-
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entiites`
663-
/// - [`EntitiesError::InvalidEntity` if `schema` is not none and any entities do not conform
662+
/// - [`EntitiesError::Duplicate`] if there are any duplicate entities in `entities`
663+
/// - [`EntitiesError::InvalidEntity`] if `schema` is not none and any entities do not conform
664664
/// to the schema
665665
/// - [`EntitiesError::Deserialization`] if there are errors while parsing the json
666666
pub fn from_json_file(

0 commit comments

Comments
 (0)