Skip to content

Commit

Permalink
chore: expose def_limit arg
Browse files Browse the repository at this point in the history
  • Loading branch information
williamfzc committed Nov 24, 2024
1 parent fb5e2b5 commit ddaa1c5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@ While there is undoubtedly a trade-off in precision, the benefits are clear:
> the areas where it is primarily used.
The method we use to demonstrate accuracy is to compare the results with those of LSP/LSIF. It must be admitted that
static inference is almost impossible to obtain all reference relationships like LSP, but in strict mode, our
calculation accuracy is still quite considerable. In normal mode, you can decide whether to adopt the relationship based
on the weight returned.
static inference is almost impossible to obtain all reference relationships like LSP.

| Repo | Precision (Strict Mode) | Graph Generated Time |
|-------------------------------------|-------------------------|----------------------|
| https://github.com/williamfzc/srctx | 80/80 = 100 % | 83.139791ms |
| https://github.com/gin-gonic/gin | 160/167 = 95.80838 % | 310.6805ms |
You can further combine your own needs and use other methods such as tfidf to process the results to meet more complex requirements.

| Repo | Coverage of LSP Edges by Gossiphs |
|----------------------------------|-----------------------------------|
| https://github.com/go-gorm/gorm | 442/499 = 88.5 % |
| https://github.com/gin-gonic/gin | 238/252 = 94.4% |

## Contribution

Expand All @@ -183,6 +183,8 @@ You just need to:
2. Test it in [src/extractor.rs](src/extractor.rs)
3. Try it with your repo in [src/graph.rs](src/graph.rs)

[Tree-sitter Playground](https://tree-sitter.github.io/tree-sitter/playground) is a good helper.

## License

[Apache 2.0](LICENSE)
7 changes: 5 additions & 2 deletions src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,20 +457,23 @@ pub struct GraphConfig {
pub project_path: String,

// a ref can only belong to limit def
#[pyo3(get, set)]
pub def_limit: usize,

// commit size limit
// reduce the impact of large commits
// large commit: edit more than xx% files once
// default to 1.0, do nothing
// set to 0.3, means 30%
#[pyo3(get, set)]
pub commit_size_limit_ratio: f32,

// commit history search depth
#[pyo3(get, set)]
pub depth: u32,

// symbol limit of each file
// symbol limit of each file, for ignoring large files
#[pyo3(get, set)]
pub symbol_limit: usize,

#[pyo3(get, set)]
Expand All @@ -487,7 +490,7 @@ impl GraphConfig {
pub fn default() -> GraphConfig {
GraphConfig {
project_path: String::from("."),
def_limit: 1,
def_limit: 4,
commit_size_limit_ratio: 1.0,
depth: 10240,
symbol_limit: 4096,
Expand Down
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ struct CommonOptions {
#[clap(default_value = "false")]
strict: bool,

#[clap(long)]
def_limit: Option<usize>,

/// git commit history search depth
#[clap(long)]
depth: Option<u32>,
Expand All @@ -80,6 +83,7 @@ impl CommonOptions {
CommonOptions {
project_path: String::from("."),
strict: false,
def_limit: None,
depth: None,
exclude_file_regex: None,
exclude_author_regex: None,
Expand Down Expand Up @@ -247,6 +251,10 @@ fn handle_relation(relation_cmd: RelationCommand) {
if relation_cmd.common_options.strict {
config.def_limit = 1;
}
if relation_cmd.common_options.def_limit.is_some() {
config.def_limit = relation_cmd.common_options.def_limit.unwrap();
}

if let Some(depth) = relation_cmd.common_options.depth {
config.depth = depth;
}
Expand Down

0 comments on commit ddaa1c5

Please sign in to comment.