Skip to content

Extract refs and packages from blocks of code #44

@rimutaka

Description

@rimutaka

Some languages have simple, one line import xyz_lib or use abc_mod type of statements, while others like Rust and Go can have nested import statements.

E.g. Go

import (
	"encoding/binary"
	"encoding/json"
	"errors"
	"net/url"
	"reflect"
	"testing"
	"time"

	. "gopkg.in/check.v1"
	"gopkg.in/mgo.v2/bson"
)

or Rust (https://github.com/matrix-org/matrix-rust-sdk/blob/main/crates/matrix-sdk/src/client.rs)

use crate::{
    config::{ClientConfig, RequestConfig},
    error::{HttpError, HttpResult},
    event_handler::{EventHandler, EventHandlerData, EventHandlerResult, EventKind, SyncEvent},
    http_client::{client_with_config, HttpClient},
    room, Error, Result,
};

Terraform has a similar problem. We need to extract source only if it's nested inside required_providers section and should never be read if it's inside module section. E.g.

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.59"
    }
    time = {
      source  = "hashicorp/time"
      version = "~> 0.7.2"
    }
    github = {
      source  = "integrations/github"
      version = "~> 4.14"
    }
  }

Reports are missing a lot of refs and packages due to this limitation. Review all munchers on completion.

Related issues: #8, #7

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions