Unverified Commit a0b60ed5 authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

Add clippy.toml with forbidden methods & fix SystemTime usages (#2882)



## Motivation and Context
- #2087 

## Description
- remove lingering usages of SystemTime::now()
- ensure they don't return by adding a clippy.toml

## Testing
- CI
- Ran the webassembly example

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: default avatarJohn DiSanti <jdisanti@amazon.com>
parent cf8df40f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
../clippy.toml
 No newline at end of file
+5 −1
Original line number Diff line number Diff line
@@ -147,7 +147,11 @@ impl PresigningConfigBuilder {
            return Err(ErrorKind::ExpiresInDurationTooLong.into());
        }
        Ok(PresigningConfig {
            start_time: self.start_time.unwrap_or_else(SystemTime::now),
            start_time: self.start_time.unwrap_or_else(
                // This usage is OK—customers can easily override this.
                #[allow(clippy::disallowed_methods)]
                SystemTime::now,
            ),
            expires_in,
        })
    }
+3 −1
Original line number Diff line number Diff line
@@ -180,12 +180,14 @@ mod tests {
    use super::RequestInfoInterceptor;
    use crate::request_info::RequestPairs;
    use aws_smithy_http::body::SdkBody;
    use aws_smithy_runtime_api::client::interceptors::context::{Input, InterceptorContext};
    use aws_smithy_runtime_api::client::interceptors::context::Input;
    use aws_smithy_runtime_api::client::interceptors::context::InterceptorContext;
    use aws_smithy_runtime_api::client::interceptors::Interceptor;
    use aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder;
    use aws_smithy_types::config_bag::{ConfigBag, Layer};
    use aws_smithy_types::retry::RetryConfig;
    use aws_smithy_types::timeout::TimeoutConfig;

    use http::HeaderValue;
    use std::time::Duration;

+8 −3
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
use aws_smithy_types::config_bag::{ConfigBag, Storable, StoreReplace};
use aws_smithy_types::date_time::Format;
use aws_smithy_types::DateTime;
use std::time::{Duration, SystemTime};
use std::time::Duration;

/// Amount of clock skew between the client and the service.
#[derive(Debug, Clone)]
@@ -72,10 +72,15 @@ impl Interceptor for ServiceClockSkewInterceptor {
    fn modify_before_deserialization(
        &self,
        ctx: &mut BeforeDeserializationInterceptorContextMut<'_>,
        _runtime_components: &RuntimeComponents,
        runtime_components: &RuntimeComponents,
        cfg: &mut ConfigBag,
    ) -> Result<(), BoxError> {
        let time_received = DateTime::from(SystemTime::now());
        let time_received = DateTime::from(
            runtime_components
                .time_source()
                .ok_or("a time source is required (service clock skew)")?
                .now(),
        );
        let time_sent = match extract_time_sent_from_response(ctx) {
            Ok(time_sent) => time_sent,
            Err(e) => {
+2 −1
Original line number Diff line number Diff line
@@ -3,8 +3,9 @@
 * SPDX-License-Identifier: Apache-2.0
 */

// TODO(enableNewSmithyRuntimeCleanup): Remove this blanket allow once the old implementations are deleted
// this code is dead
#![allow(deprecated)]
#![allow(clippy::disallowed_methods)]

use crate::middleware::Signature;
use aws_credential_types::Credentials;
Loading