stackmuncher / stm_app

This software engineer profile builder turns your code into a detailed list of skills for an online directory of software developers.
https://stackmuncher.com
GNU Affero General Public License v3.0
22 stars 1 forks source link

Extract refs and packages from blocks of code #44

Open rimutaka opened 2 years ago

rimutaka commented 2 years ago

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