@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
69 lines (68 loc) • 4.45 kB
TypeScript
import { type LintingResult, LintingResultCertainty, LintingRuleCertainty } from '../linter-format';
import { SourceLocation } from '../../util/range';
import type { MergeableRecord } from '../../util/objects';
import type { BrandedIdentifier } from '../../dataflow/environments/identifier';
import { LintingRuleTag } from '../linter-tags';
export interface SeededRandomnessResult extends LintingResult {
function: string;
loc: SourceLocation;
}
export interface SeededRandomnessConfig extends MergeableRecord {
/**
* A set of functions and variables whose invocation or assignment causes a random seeded to be set.
* Each entry has a `type`, which is either `function` or `assignment`, and a `name`, which is the name of the function or variable.
* The default value for this is the function `set.seed` and the variable `.Random.seed`.
*/
randomnessProducers: {
type: 'function' | 'assignment';
name: string;
}[];
/**
* A set of randomness consumer function names that require a seed to be set prior to invocation.
*/
randomnessConsumers: string[];
}
export interface SeededRandomnessMeta extends MergeableRecord {
consumerCalls: number;
callsWithFunctionProducers: number;
callsWithAssignmentProducers: number;
callsWithNonConstantProducers: number;
callsWithOtherBranchProducers: number;
}
export declare const SEEDED_RANDOMNESS: {
readonly createSearch: (config: SeededRandomnessConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with", "filter", "with"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: SeededRandomnessConfig, { dataflow, analyzer }: {
normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
dataflow: import("../../dataflow/info").DataflowInformation;
cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
}) => {
results: {
involvedId: import("../../r-bridge/lang-4.x/ast/model/processing/node-id").NodeId;
certainty: LintingResultCertainty;
function: BrandedIdentifier;
loc: [startLine: number, startColumn: number, endLine: number, endColumn: number, f?: string | undefined];
}[];
'.meta': SeededRandomnessMeta;
};
readonly info: {
readonly defaultConfig: {
readonly randomnessProducers: readonly [{
readonly type: "function";
readonly name: "set.seed";
}, {
readonly type: "assignment";
readonly name: ".Random.seed";
}];
readonly randomnessConsumers: readonly ["jitter", "sample", "sample.int", "arima.sim", "kmeans", "princomp", "rcauchy", "rchisq", "rexp", "rgamma", "rgeom", "rlnorm", "rlogis", "rmultinom", "rnbinom", "rnorm", "rpois", "runif", "pointLabel", "some", "rbernoulli", "rdunif", "generateSeedVectors"];
};
readonly tags: readonly [LintingRuleTag.Robustness, LintingRuleTag.Reproducibility];
readonly certainty: LintingRuleCertainty.BestEffort;
readonly name: "Seeded Randomness";
readonly description: "Checks whether randomness-based function calls are preceded by a random seed generation function. For consistent reproducibility, functions that use randomness should only be called after a constant random seed is set using a function like `set.seed`.";
};
readonly prettyPrint: {
readonly query: (result: SeededRandomnessResult, _meta: SeededRandomnessMeta) => string;
readonly full: (result: SeededRandomnessResult, _meta: SeededRandomnessMeta) => string;
};
};