[Linter]: Support for deprecated arguments - #2630
Conversation
|
Questions:
|
Just for the argument please
unsure what you mean here because the argument names cannot be namespaced? Could you please elaborate with an example? |
|
|
Aah okay so you can use either |
|
Sounds like it, I will try that! Thank you! |
db3f78d to
e515c3b
Compare
| hardcoded: number | ||
| } | ||
|
|
||
| const AlwaysDeprecated = [ |
There was a problem hiding this comment.
can we map these to the built in call props
| 'all_equal', 'arrange_all', 'distinct_all', 'filter_all', 'group_by_all', 'summarise_all', 'mutate_all', 'select_all', 'vars', 'all_vars', 'id', 'failwith', 'select_vars', 'rename_vars', 'select_var', 'current_vars', 'bench_tbls', 'compare_tbls', 'compare_tbls2', 'eval_tbls', 'eval_tbls2', 'location', 'changes', 'combine', 'do', 'funs', 'add_count_', 'add_tally_', 'arrange1_', 'count_', 'distinct_', 'do_', 'filter_', 'funs_', 'group_by_', 'group_indices_', 'mutate_', 'tally_', 'transmute_', 'rename_', 'rename_vars_', 'select_', 'select_vars_', 'slice_', 'summarise_', 'summarize_', 'summarise_each', 'src_local', 'tbl_df', 'add_rownames', 'group_nest', 'group_split', 'with_groups', 'nest_by', 'progress_estimated', 'recode', 'sample_n', 'top_n', 'transmute', 'fct_explicit_na', 'aes_', 'aes_auto', 'annotation_logticks', 'is.Coord', 'coord_flip', 'coord_map', 'is.facet', 'fortify', 'is.ggproto', 'guide_train', 'is.ggplot', 'qplot', 'is.theme', 'gg_dep', 'liply', 'isplit2', 'list_along', 'cross', 'invoke', 'at_depth', 'prepend', 'rerun', 'splice', '`%@%`', 'rbernoulli', 'rdunif', 'when', 'update_list', 'map_raw', 'accumulate', 'reduce_right', 'flatten', 'map_dfr', 'as_vector', 'transpose', 'melt_delim', 'melt_fwf', 'melt_table', 'read_table2', 'str_interp', 'as_tibble', 'data_frame', 'tibble_', 'data_frame_', 'lst_', 'as_data_frame', 'as.tibble', 'frame_data', 'trunc_mat', 'is.tibble', 'tidy_names', 'set_tidy_names', 'repair_names', 'extract_numeric', 'complete_', 'drop_na_', 'expand_', 'crossing_', 'nesting_', 'extract_', 'fill_', 'gather_', 'nest_', 'separate_rows_', 'separate_', 'spread_', 'unite_', 'unnest_', 'extract', 'gather', 'nest_legacy', 'separate_rows', 'separate', 'spread' | ||
| ]; | ||
|
|
||
| const ConditionallyDeprecated = { |
There was a problem hiding this comment.
nice as an example :) maybe reference the deprecation notice/url?
| export interface DeprecatedArgumentResult extends DeprecatedFunctionResultBase { | ||
| readonly type: 'deprecated-argument' | ||
| /** The name or index of the deprecated argument */ | ||
| readonly arg: string | number |
There was a problem hiding this comment.
this does not make it clear what this will contain. like why allow both? every parameter has a name so there should be one. is this automatically a name if it was given named and index if unnamed?
| /** A better alternative is available, and the function is marked for removal {@link https://lifecycle.r-lib.org/articles/stages.html#deprecated} */ | ||
| Deprecated = 'deprecated', | ||
| /** No longer works and is removed and replaced by another function {@link https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/Defunct} */ | ||
| Defunct = 'defunct' |
There was a problem hiding this comment.
is defunct associated with exceptions? if so we could pipe this into flowR's exception handling
| } | ||
|
|
||
| interface Metadata extends MergeableRecord { | ||
| sigdb: number, |
There was a problem hiding this comment.
does this code the number of hits from the sigdb, the number of entries in the sigdb.... this should be made clearer
| */ | ||
| async function deprecateFunctionConditionally(candidate: PotentialFunction, dataflow: DataflowGraph, idMap: AstIdMap, analyzer: ReadonlyFlowrAnalysisProvider<KnownParser>, info: DeprecatedFunctionInformation): Promise<DeprecatedFunctionRuleResult[]> { | ||
| const results: DeprecatedFunctionRuleResult[] = []; | ||
| const result = await analyzer.query([{ |
There was a problem hiding this comment.
uuuh this is a performance hazard. check whether you need to do this first, then do it once and take the info. even if you guess just one package this has to solve a big system.
| const name = candidate.target.includes('::') ? Identifier.getName(Identifier.parse(candidate.target)) : candidate.target; | ||
| const info = config.conditionally[name]; | ||
| if(isNotUndefined(info)) { | ||
| // Check functions from DeprecatedFunctionsConfig.conditionally |
There was a problem hiding this comment.
any reasons for these comments?
|
|
||
| // 2. Uses hardcoded information about deprecated arguments and deprecated functions | ||
| const results: DeprecatedFunctionRuleResult[] = (await Promise.all(detectedFunctions.map(async candidate => { | ||
| const name = candidate.target.includes('::') ? Identifier.getName(Identifier.parse(candidate.target)) : candidate.target; |
There was a problem hiding this comment.
why even check for :: Identifier shuold be doing this just fine! I nmean its technically fine as a safe guard but this could go south
|
|
||
| // Deprecated Argument: If `whenArgs` is provided, only mark deprecated arguments | ||
| if(info.whenArgs) { | ||
| const vertex = dataflow.getVertex(candidate.node.info.id); |
There was a problem hiding this comment.
could we please structure this into helper functions? :D
| /** | ||
| * Test if a function call has an argument with a specific value | ||
| */ | ||
| export function hasArgumentValue( |
There was a problem hiding this comment.
this could be.. should be moved in to the Rargument helper object i think
closes #1870
TODO: