r-lib / lintr

Static Code Analysis for R
https://lintr.r-lib.org
Other
1.2k stars 187 forks source link

`namespace_imports()` gets confused by `except` argument in `import()` #2200

Closed Bisaloo closed 1 year ago

Bisaloo commented 1 year ago

This is a very unusual situation but I have detected via https://github.com/bernadette-eu/Bernadette/pull/10 that namespace_imports() parse import(pkg, except = fct) calls in NAMESPACE in the same way as importFrom(pkg, fct).

You can find a test pkg here: https://github.com/Bisaloo/importexceptdemo where you can reproduce the issue by running lintr:::namespace_imports()

Output:

pkg fun

1 stats lag

Expected output (all of stats excepted `lag()`) > pkg fun > 1 stats asOneSidedFormula > 2 stats r2dtable > 3 stats drop.terms > 4 stats confint.lm > 5 stats is.mts > 6 stats nlminb > 7 stats alias > 8 stats gaussian > 9 stats profile > 10 stats ls.diag > 11 stats mahalanobis > 12 stats rmultinom > 13 stats dpois > 14 stats numericDeriv > 15 stats makepredictcall > 16 stats qlogis > 17 stats loadings > 18 stats dlogis > 19 stats nlm > 20 stats residuals.glm > 21 stats qcauchy > 22 stats nextn > 23 stats nls > 24 stats plot.stepfun > 25 stats arima0.diag > 26 stats dummy.coef > 27 stats ftable > 28 stats as.formula > 29 stats pairwise.wilcox.test > 30 stats time > 31 stats embed > 32 stats mantelhaen.test > 33 stats dwilcox > 34 stats ar > 35 stats oneway.test > 36 stats fligner.test > 37 stats bw.bcv > 38 stats predict.glm > 39 stats rWishart > 40 stats logLik > 41 stats confint.default > 42 stats AIC > 43 stats rlogis > 44 stats bw.ucv > 45 stats arima > 46 stats plot.ts > 47 stats tsp > 48 stats model.extract > 49 stats tsp<- > 50 stats stat.anova > 51 stats update.formula > 52 stats qbeta > 53 stats bw.SJ > 54 stats factanal > 55 stats drop.scope > 56 stats summary.aov > 57 stats optimHess > 58 stats .lm.fit > 59 stats cooks.distance > 60 stats dnorm > 61 stats psmirnov > 62 stats extractAIC > 63 stats qbirthday > 64 stats C > 65 stats sortedXyData > 66 stats D > 67 stats lowess > 68 stats varimax > 69 stats optimize > 70 stats manova > 71 stats deviance > 72 stats optim > 73 stats lag.plot > 74 stats constrOptim > 75 stats splinefunH > 76 stats reformulate > 77 stats pacf > 78 stats mcnemar.test > 79 stats df > 80 stats tsSmooth > 81 stats make.link > 82 stats glm.control > 83 stats hasTsp > 84 stats pgamma > 85 stats addmargins > 86 stats dexp > 87 stats power.anova.test > 88 stats prop.test > 89 stats model.weights > 90 stats ave > 91 stats is.stepfun > 92 stats heatmap > 93 stats stepfun > 94 stats loess.smooth > 95 stats window<- > 96 stats line > 97 stats qqline > 98 stats ar.mle > 99 stats residuals > 100 stats lsfit > 101 stats get_all_vars > 102 stats dt > 103 stats splinefun > 104 stats ks.test > 105 stats cor > 106 stats add.scope > 107 stats ecdf > 108 stats pwilcox > 109 stats cov > 110 stats dendrapply > 111 stats rsignrank > 112 stats bandwidth.kernel > 113 stats as.dist > 114 stats SSweibull > 115 stats bw.nrd > 116 stats start > 117 stats plnorm > 118 stats ts.union > 119 stats mvfft > 120 stats dweibull > 121 stats as.ts > 122 stats cor.test > 123 stats .checkMFClasses > 124 stats effects > 125 stats reorder > 126 stats KalmanForecast > 127 stats eff.aovlist > 128 stats qgamma > 129 stats glm.fit > 130 stats plot.spec.coherency > 131 stats dgamma > 132 stats cov2cor > 133 stats ls.print > 134 stats setNames > 135 stats acf2AR > 136 stats add1 > 137 stats rcauchy > 138 stats shapiro.test > 139 stats deriv3 > 140 stats window > 141 stats model.tables > 142 stats model.matrix > 143 stats .nknots.smspl > 144 stats KalmanLike > 145 stats SSasymp > 146 stats predict > 147 stats as.stepfun > 148 stats t.test > 149 stats power.prop.test > 150 stats rstandard > 151 stats binom.test > 152 stats cophenetic > 153 stats pbeta > 154 stats KalmanRun > 155 stats naprint > 156 stats qlnorm > 157 stats plclust > 158 stats model.response > 159 stats dlnorm > 160 stats lag > 161 stats spec.pgram > 162 stats interaction.plot > 163 stats fitted > 164 stats rgeom > 165 stats estVar > 166 stats rgamma > 167 stats arima0 > 168 stats loglin > 169 stats ar.yw > 170 stats promax > 171 stats phyper > 172 stats drop1 > 173 stats SSfol > 174 stats runif > 175 stats family > 176 stats quantile > 177 stats wilcox.test > 178 stats psignrank > 179 stats complete.cases > 180 stats offset > 181 stats scatter.smooth > 182 stats dmultinom > 183 stats rlnorm > 184 stats approx > 185 stats naresid > 186 stats SSfpl > 187 stats proj > 188 stats supsmu > 189 stats qqnorm > 190 stats end > 191 stats printCoefmat > 192 stats princomp > 193 stats aggregate.data.frame > 194 stats dnbinom > 195 stats lm.influence > 196 stats rect.hclust > 197 stats convolve > 198 stats ansari.test > 199 stats median.default > 200 stats ARMAacf > 201 stats poly > 202 stats NLSstRtAsymptote > 203 stats power.t.test > 204 stats write.ftable > 205 stats qhyper > 206 stats polym > 207 stats weights > 208 stats dhyper > 209 stats contrasts<- > 210 stats kernel > 211 stats friedman.test > 212 stats acf > 213 stats qwilcox > 214 stats filter > 215 stats lm.fit > 216 stats rpois > 217 stats cmdscale > 218 stats factor.scope > 219 stats Gamma > 220 stats pweibull > 221 stats pchisq > 222 stats ksmooth > 223 stats symnum > 224 stats smooth > 225 stats quasipoisson > 226 stats ppr > 227 stats spec.ar > 228 stats pnbinom > 229 stats coefficients > 230 stats model.offset > 231 stats dbeta > 232 stats SSasympOff > 233 stats pbirthday > 234 stats replications > 235 stats ar.ols > 236 stats rhyper > 237 stats spectrum > 238 stats lm > 239 stats expand.model.frame > 240 stats kernapply > 241 stats bw.nrd0 > 242 stats stl > 243 stats loess > 244 stats IQR > 245 stats qgeom > 246 stats contr.helmert > 247 stats na.pass > 248 stats toeplitz > 249 stats pairwise.t.test > 250 stats dist > 251 stats .getXlevels > 252 stats NLSstClosestX > 253 stats getInitial > 254 stats sigma > 255 stats qchisq > 256 stats contr.poly > 257 stats dchisq > 258 stats spline > 259 stats qunif > 260 stats confint > 261 stats pairwise.table > 262 stats SSasympOrig > 263 stats pexp > 264 stats plot.spec.phase > 265 stats density.default > 266 stats medpolish > 267 stats ptukey > 268 stats cancor > 269 stats Box.test > 270 stats TukeyHSD > 271 stats rnorm > 272 stats var.test > 273 stats poisson > 274 stats bartlett.test > 275 stats summary.stepfun > 276 stats na.fail > 277 stats model.frame > 278 stats covratio > 279 stats contrasts > 280 stats ar.burg > 281 stats residuals.lm > 282 stats df.residual > 283 stats ts.intersect > 284 stats power > 285 stats SSlogis > 286 stats glm > 287 stats rchisq > 288 stats getCall > 289 stats model.matrix.lm > 290 stats chisq.test > 291 stats coef > 292 stats step > 293 stats ppoints > 294 stats vcov > 295 stats .preformat.ts > 296 stats qqplot > 297 stats DF2formula > 298 stats update.default > 299 stats qtukey > 300 stats quade.test > 301 stats qpois > 302 stats df.kernel > 303 stats influence > 304 stats qsmirnov > 305 stats cutree > 306 stats poisson.test > 307 stats pf > 308 stats case.names > 309 stats frequency > 310 stats tsdiag > 311 stats qweibull > 312 stats NLSstLfAsymptote > 313 stats kmeans > 314 stats weighted.residuals > 315 stats mauchly.test > 316 stats napredict > 317 stats qexp > 318 stats deriv > 319 stats var > 320 stats aggregate.ts > 321 stats rwilcox > 322 stats SSbiexp > 323 stats pt > 324 stats rsmirnov > 325 stats qf > 326 stats xtabs > 327 stats kruskal.test > 328 stats median > 329 stats as.hclust > 330 stats termplot > 331 stats rweibull > 332 stats resid > 333 stats pgeom > 334 stats qnbinom > 335 stats se.contrast > 336 stats summary.manova > 337 stats prcomp > 338 stats preplot > 339 stats plot.ecdf > 340 stats arima.sim > 341 stats lm.wfit > 342 stats ccf > 343 stats is.leaf > 344 stats na.action > 345 stats screeplot > 346 stats approxfun > 347 stats NLSstAsymptotic > 348 stats order.dendrogram > 349 stats cycle > 350 stats qt > 351 stats rf > 352 stats punif > 353 stats quasi > 354 stats ts.plot > 355 stats cov.wt > 356 stats mood.test > 357 stats PP.test > 358 stats is.empty.model > 359 stats loess.control > 360 stats decompose > 361 stats aggregate > 362 stats BIC > 363 stats reshape > 364 stats makeARIMA > 365 stats ARMAtoMA > 366 stats weighted.mean > 367 stats pbinom > 368 stats selfStart > 369 stats SSgompertz > 370 stats qnorm > 371 stats inverse.gaussian > 372 stats na.omit > 373 stats sd > 374 stats rt > 375 stats fft > 376 stats dcauchy > 377 stats fivenum > 378 stats toeplitz2 > 379 stats relevel > 380 stats summary.glm > 381 stats rexp > 382 stats monthplot > 383 stats dfbeta > 384 stats diffinv > 385 stats nobs > 386 stats SSmicmen > 387 stats is.ts > 388 stats dummy.coef.lm > 389 stats hatvalues > 390 stats variable.names > 391 stats Pair > 392 stats model.frame.default > 393 stats anova > 394 stats simulate > 395 stats dffits > 396 stats model.matrix.default > 397 stats contr.SAS > 398 stats contr.treatment > 399 stats predict.lm > 400 stats prop.trend.test > 401 stats as.dendrogram > 402 stats ppois > 403 stats pcauchy > 404 stats smoothEnds > 405 stats qbinom > 406 stats hat > 407 stats p.adjust > 408 stats .MFclass > 409 stats dbinom > 410 stats terms.formula > 411 stats spec.taper > 412 stats HoltWinters > 413 stats ts > 414 stats na.exclude > 415 stats dsignrank > 416 stats is.tskernel > 417 stats fitted.values > 418 stats qsignrank > 419 stats integrate > 420 stats optimise > 421 stats binomial > 422 stats KalmanSmooth > 423 stats .vcov.aliased > 424 stats deltat > 425 stats p.adjust.methods > 426 stats SSD > 427 stats summary.lm > 428 stats smooth.spline > 429 stats rstudent > 430 stats hclust > 431 stats density > 432 stats dgeom > 433 stats terms > 434 stats fisher.test > 435 stats rbinom > 436 stats formula > 437 stats nls.control > 438 stats isoreg > 439 stats contr.sum > 440 stats uniroot > 441 stats quasibinomial > 442 stats dunif > 443 stats influence.measures > 444 stats na.contiguous > 445 stats dfbetas > 446 stats pairwise.prop.test > 447 stats rnbinom > 448 stats pnorm > 449 stats rbeta > 450 stats cpgram > 451 stats knots > 452 stats biplot > 453 stats runmed > 454 stats mad > 455 stats delete.response > 456 stats plogis > 457 stats read.ftable > 458 stats aov > 459 stats update > 460 stats StructTS
IndrajeetPatil commented 1 year ago

Duplicate of #1397?

Bisaloo commented 1 year ago

Yes, you're right. I should have checked beforehand. Thanks!