Repository: denoland/deno
File: cli/tools/registry/pm/deps.rs (Rust)

Code before:
    &self,
  ) -> Result<Vec<PackageLatestVersion>, AnyError> {
    if self.latest_versions.len() == self.deps.len() {
      return Ok(self.latest_versions.clone());
    }
    let mut latest_versions = Vec::with_capacity(self.deps.len());

    let npm_sema = Semaphore::new(32);
    let jsr_sema = Semaphore::new(32);
    let mut futs = FuturesOrdered::new();

    for dep in &self.deps {
      match dep.kind {
        DepKind::Npm => futs.push_back(
          async {
            let semver_req = &dep.req;
            let _permit = npm_sema.acquire().await;
            let semver_compatible =
              self.npm_fetch_resolver.req_to_nv(semver_req).await;
            let info =
              self.npm_fetch_resolver.package_info(&semver_req.name).await;
            let latest = info
              .and_then(|info| {
                let latest_tag = info.dist_tags.get("latest")?;
                let lower_bound =
                  semver_compatible.as_ref().map(|nv| &nv.version)?;
                if latest_tag > lower_bound {
                  Some(latest_tag.clone())
                } else {
                  latest_version(Some(latest_tag), info.versions.keys())
                }
              })
              .map(|version| PackageNv {
                name: semver_req.name.clone(),
                version: version.clone(),
              });
            PackageLatestVersion {
              latest,
              semver_compatible,
            }
          }
          .boxed_local(),
        ),
        DepKind::Jsr => futs.push_back(
          async {
            let semver_req = &dep.req;
            let _permit = jsr_sema.acquire().await;
            let semver_compatible =
              self.jsr_fetch_resolver.req_to_nv(semver_req).await;
            let info =
              self.jsr_fetch_resolver.package_info(&semver_req.name).await;

Review comment (suggestion):
```suggestion
                  semver_compatible.as_ref()?.version;
```

Code after:
    let npm_sema = Semaphore::new(32);
    let jsr_sema = Semaphore::new(32);
    let mut futs = FuturesOrdered::new();

    for dep in &self.deps {
      match dep.kind {
        DepKind::Npm => futs.push_back(
          async {
            let semver_req = &dep.req;
            let _permit = npm_sema.acquire().await;
            let semver_compatible =
              self.npm_fetch_resolver.req_to_nv(semver_req).await;
            let info =
              self.npm_fetch_resolver.package_info(&semver_req.name).await;
            let latest = info
              .and_then(|info| {
                let latest_tag = info.dist_tags.get("latest")?;
                let lower_bound = &semver_compatible.as_ref()?.version;
                if latest_tag > lower_bound {
                  Some(latest_tag.clone())
                } else {
                  latest_version(Some(latest_tag), info.versions.keys())
                }
              })
              .map(|version| PackageNv {
                name: semver_req.name.clone(),
                version,
              });
            PackageLatestVersion {
              latest,
              semver_compatible,
            }
          }
          .boxed_local(),
        ),
        DepKind::Jsr => futs.push_back(
          async {
            let semver_req = &dep.req;
            let _permit = jsr_sema.acquire().await;
            let semver_compatible =
              self.jsr_fetch_resolver.req_to_nv(semver_req).await;
            let info =
              self.jsr_fetch_resolver.package_info(&semver_req.name).await;
            let latest = info
              .and_then(|info| {
                let lower_bound = &semver_compatible.as_ref()?.version;
                latest_version(
                  Some(lower_bound),
                  info.versions.iter().filter_map(|(version, version_info)| {
                    if !version_info.yanked {
                      Some(version)