Merge pull request #8796 from erik-krogh/redundantImport

Remove redundant imports
This commit is contained in:
Erik Krogh Kristensen
2022-04-27 12:39:51 +02:00
committed by GitHub
114 changed files with 87 additions and 120 deletions

View File

@@ -4,7 +4,6 @@
import semmle.code.cpp.Variable
import semmle.code.cpp.Enum
import semmle.code.cpp.exprs.Access
/**
* A C structure member or C++ non-static member variable. For example the

View File

@@ -11,7 +11,6 @@ private import TranslatedDeclarationEntry
private import TranslatedElement
private import TranslatedFunction
private import TranslatedInitialization
private import TranslatedFunction
private import TranslatedStmt
private import TranslatedGlobalVar
import TranslatedCall

View File

@@ -5,7 +5,6 @@
import semmle.code.cpp.Function
import semmle.code.cpp.models.interfaces.ArrayFunction
import semmle.code.cpp.models.interfaces.ArrayFunction
import semmle.code.cpp.models.interfaces.Alias
import semmle.code.cpp.models.interfaces.SideEffect
import semmle.code.cpp.models.interfaces.Taint

View File

@@ -1802,5 +1802,3 @@ module SimpleRangeAnalysisInternal {
defMightOverflowNegatively(def, v) and result = varMaxVal(v)
}
}
private import SimpleRangeAnalysisInternal

View File

@@ -6,7 +6,6 @@
*/
import cpp
import semmle.code.cpp.commons.Alloc
import semmle.code.cpp.commons.Buffer
import semmle.code.cpp.commons.Scanf
import semmle.code.cpp.models.implementations.Strcat

View File

@@ -13,7 +13,6 @@
import cpp
import LeapYear
import semmle.code.cpp.dataflow.DataFlow
from Expr source, Expr sink, PossibleYearArithmeticOperationCheckConfiguration config
where config.hasFlow(DataFlow::exprNode(source), DataFlow::exprNode(sink))

View File

@@ -10,7 +10,6 @@
import cpp
import NtohlArrayNoBound
import semmle.code.cpp.dataflow.DataFlow
from NetworkToBufferSizeConfiguration bufConfig, DataFlow::Node source, DataFlow::Node sink
where bufConfig.hasFlow(source, sink)

View File

@@ -15,7 +15,6 @@
*/
import semmle.code.cpp.security.BufferWrite
import semmle.code.cpp.commons.Alloc
/*
* See CWE-120/UnboundedWrite.ql for a summary of CWE-120 alert cases.

View File

@@ -15,7 +15,6 @@
*/
import semmle.code.cpp.security.BufferWrite
import semmle.code.cpp.commons.Alloc
/*
* See CWE-120/UnboundedWrite.ql for a summary of CWE-120 alert cases.

View File

@@ -16,7 +16,6 @@
*/
import cpp
import semmle.code.cpp.exprs.BitwiseOperation
import semmle.code.cpp.valuenumbering.GlobalValueNumbering
/**

View File

@@ -4,7 +4,6 @@
import semmle.code.cpp.ir.dataflow.DataFlow
import IRConfiguration
import cpp
import DataFlow::PathGraph
from DataFlow::PathNode src, DataFlow::PathNode sink, IRConf conf

View File

@@ -4,7 +4,6 @@
import semmle.code.cpp.dataflow.DataFlow
import ASTConfiguration
import cpp
import DataFlow::PathGraph
from DataFlow::PathNode src, DataFlow::PathNode sink, AstConf conf

View File

@@ -3,7 +3,6 @@
private import csharp
private import AssignableDefinitions
private import SsaImpl as SsaImpl
private import semmle.code.csharp.dataflow.SSA
class BasicBlock = ControlFlow::BasicBlock;

View File

@@ -5,7 +5,6 @@
*/
import Expr
import semmle.code.csharp.Callable
import semmle.code.csharp.dataflow.CallContext as CallContext
private import semmle.code.csharp.dataflow.internal.DelegateDataFlow
private import semmle.code.csharp.dataflow.internal.DataFlowDispatch

View File

@@ -3,7 +3,6 @@
*/
import Expr
import semmle.code.csharp.Callable
private import semmle.code.csharp.frameworks.system.linq.Expressions
private import semmle.code.csharp.TypeRef

View File

@@ -15,7 +15,6 @@ import Dynamic
import Literal
import LogicalOperation
import semmle.code.csharp.controlflow.ControlFlowElement
import semmle.code.csharp.Callable
import semmle.code.csharp.Location
import semmle.code.csharp.Stmt
import semmle.code.csharp.Type

View File

@@ -5,7 +5,6 @@
import csharp
private import semmle.code.csharp.dataflow.flowsources.Remote
private import semmle.code.csharp.dataflow.TaintTracking
private import semmle.code.csharp.frameworks.System
private import semmle.code.csharp.dataflow.FlowSummary

View File

@@ -1,6 +1,4 @@
import csharp
import semmle.code.csharp.dataflow.DataFlow
import csharp
class ImplementsICryptoTransform extends Class {
ImplementsICryptoTransform() {

View File

@@ -11,7 +11,6 @@
import csharp
import DataFlow::PathGraph
import semmle.code.csharp.dataflow.TaintTracking
class UnsafeYearCreationFromArithmeticConfiguration extends TaintTracking::Configuration {
UnsafeYearCreationFromArithmeticConfiguration() {

View File

@@ -1,5 +1,4 @@
import csharp
import semmle.code.csharp.dataflow.DataFlow
abstract class ParallelSink extends DataFlow::Node { }

View File

@@ -15,7 +15,6 @@
*/
import csharp
import semmle.code.csharp.dataflow.DataFlow
import ParallelSink
import ICryptoTransform

View File

@@ -10,7 +10,6 @@
*/
import csharp
import semmle.code.csharp.dataflow.TaintTracking
import semmle.code.csharp.security.dataflow.ExternalAPIsQuery
import DataFlow::PathGraph

View File

@@ -14,7 +14,6 @@
import csharp
import semmle.code.csharp.security.dataflow.flowsources.Remote
import semmle.code.csharp.security.dataflow.flowsources.Local
import semmle.code.csharp.dataflow.TaintTracking
import semmle.code.csharp.frameworks.Format
import DataFlow::PathGraph

View File

@@ -14,7 +14,6 @@
import csharp
import semmle.code.asp.WebConfig
import semmle.code.csharp.XML
class Application_Error extends Method {
Application_Error() {

View File

@@ -2,13 +2,11 @@
private import csharp
private import semmle.code.csharp.dispatch.Dispatch
private import semmle.code.csharp.dataflow.DataFlow
private import semmle.code.csharp.dataflow.ExternalFlow
private import semmle.code.csharp.dataflow.FlowSummary
private import semmle.code.csharp.dataflow.internal.DataFlowImplCommon as DataFlowImplCommon
private import semmle.code.csharp.dataflow.internal.DataFlowPrivate
private import semmle.code.csharp.dataflow.internal.DataFlowDispatch as DataFlowDispatch
private import semmle.code.csharp.dataflow.TaintTracking
private import semmle.code.csharp.dataflow.internal.TaintTrackingPrivate
private import semmle.code.csharp.security.dataflow.flowsources.Remote

View File

@@ -10,7 +10,6 @@
import csharp
import semmle.code.csharp.dataflow.DataFlow2
import semmle.code.csharp.dataflow.TaintTracking
import semmle.code.csharp.dataflow.TaintTracking2
import DataFlow::PathGraph

View File

@@ -13,7 +13,6 @@ private import TranslatedExpr
private import TranslatedStmt
private import desugar.Foreach
private import TranslatedFunction
private import experimental.ir.Util
private import experimental.ir.internal.IRCSharpLanguage as Language
TranslatedElement getInstructionTranslatedElement(Instruction instruction) {

View File

@@ -5,7 +5,6 @@ private import InstructionTag
private import TranslatedElement
private import TranslatedExpr
private import TranslatedInitialization
private import experimental.ir.Util
private import experimental.ir.implementation.raw.internal.common.TranslatedCallBase
private import experimental.ir.internal.IRCSharpLanguage as Language

View File

@@ -10,7 +10,6 @@ private import TranslatedCondition
private import TranslatedFunction
private import TranslatedStmt
private import IRConstruction
private import experimental.ir.Util
private import experimental.ir.internal.IRCSharpLanguage as Language
private import desugar.Foreach
private import desugar.Delegate

View File

@@ -16,7 +16,6 @@ private import common.TranslatedExprBase
private import desugar.Delegate
private import desugar.internal.TranslatedCompilerGeneratedCall
import TranslatedCall
private import experimental.ir.Util
private import experimental.ir.internal.IRCSharpLanguage as Language
/**

View File

@@ -11,7 +11,6 @@ private import InstructionTag
private import TranslatedElement
private import TranslatedExpr
private import TranslatedFunction
private import experimental.ir.Util
private import IRInternal
private import desugar.Delegate

View File

@@ -9,7 +9,6 @@ private import experimental.ir.implementation.internal.OperandTag
private import experimental.ir.implementation.raw.internal.InstructionTag
private import experimental.ir.implementation.raw.internal.TranslatedElement
private import experimental.ir.implementation.raw.internal.TranslatedExpr
private import experimental.ir.Util
private import experimental.ir.internal.CSharpType
private import experimental.ir.internal.IRCSharpLanguage as Language
private import TranslatedExprBase

View File

@@ -1,5 +1,4 @@
import csharp
import semmle.code.csharp.Comments
/**
* A class representing line comments in C# used by the InlineExpectations core code

View File

@@ -1,5 +1,4 @@
import csharp
import semmle.code.csharp.dataflow.TaintTracking
// Test that all the copies of the taint tracking library can be imported
// simultaneously without errors.
import semmle.code.csharp.dataflow.TaintTracking2

View File

@@ -1,5 +1,4 @@
import semmle.code.csharp.commons.Disposal
import csharp
from Variable v
where

View File

@@ -1,5 +1,4 @@
import csharp
import semmle.code.csharp.dataflow.TaintTracking
from DataFlow::Node pred, DataFlow::Node succ
where

View File

@@ -1,5 +1,4 @@
import csharp
import semmle.code.csharp.dataflow.TaintTracking
from StringLiteral l, DataFlow::Node n
where TaintTracking::localTaintStep+(DataFlow::exprNode(l), n)

View File

@@ -1,5 +1,4 @@
import csharp
import semmle.code.csharp.dataflow.TaintTracking
class Configuration extends TaintTracking::Configuration {
Configuration() { this = "Json.NET test" }

View File

@@ -1,5 +1,4 @@
import csharp
import semmle.code.csharp.dataflow.TaintTracking
class MyConfiguration extends TaintTracking::Configuration {
MyConfiguration() { this = "MyConfiguration" }

View File

@@ -7,7 +7,6 @@
import javascript
private import semmle.javascript.heuristics.SyntacticHeuristics
private import semmle.javascript.security.dataflow.NosqlInjectionCustomizations
private import semmle.javascript.security.TaintedObject
import AdaptiveThreatModeling
private import CoreKnowledge as CoreKnowledge
private import StandardEndpointFilters as StandardEndpointFilters

View File

@@ -4,7 +4,6 @@
import javascript
import DOMProperties
import semmle.javascript.frameworks.xUnit
/**
* Holds if `e` appears in a syntactic context where its value is discarded.

View File

@@ -3,7 +3,6 @@
*/
import javascript
import semmle.javascript.Promises
/** Provices classes for modelling NoSQL query sinks. */
module NoSql {

View File

@@ -3,7 +3,6 @@
*/
import javascript
import semmle.javascript.Promises
module SQL {
/** A string-valued expression that is interpreted as a SQL command. */

View File

@@ -3,7 +3,6 @@
*/
import javascript
import semmle.javascript.frameworks.xUnit
import semmle.javascript.frameworks.TestingCustomizations
/**

View File

@@ -6,7 +6,6 @@
import javascript
private import semmle.javascript.security.SensitiveActions
private import semmle.javascript.frameworks.CryptoLibraries
module BrokenCryptoAlgorithm {
/**

View File

@@ -1,7 +1,6 @@
/** DEPRECATED. Import `ClientSideUrlRedirectQuery` instead. */
import javascript
import semmle.javascript.security.dataflow.RemoteFlowSources
import UrlConcatenation
private import ClientSideUrlRedirectQuery as ClientSideUrlRedirectQuery // ignore-query-import

View File

@@ -5,7 +5,6 @@
*/
import javascript
import semmle.javascript.security.dataflow.RemoteFlowSources
module ClientSideUrlRedirect {
/**

View File

@@ -8,7 +8,6 @@
*/
import javascript
import semmle.javascript.security.dataflow.RemoteFlowSources
import UrlConcatenation
import ClientSideUrlRedirectCustomizations::ClientSideUrlRedirect

View File

@@ -5,7 +5,6 @@
*/
import javascript
import semmle.javascript.security.dataflow.RemoteFlowSources
module CommandInjection {
/**

View File

@@ -1,7 +1,6 @@
/** DEPRECATED. Import `DifferentKindsComparisonBypassQuery` instead. */
import javascript
import semmle.javascript.security.dataflow.RemoteFlowSources
private import DifferentKindsComparisonBypassQuery as DifferentKindsComparisonBypassQuery // ignore-query-import
/** DEPRECATED. Import `DifferentKindsComparisonBypassQuery` instead. */

View File

@@ -5,7 +5,6 @@
*/
import javascript
import semmle.javascript.security.dataflow.RemoteFlowSources
module DifferentKindsComparisonBypass {
/**

View File

@@ -9,7 +9,6 @@
*/
import javascript
import semmle.javascript.security.dataflow.RemoteFlowSources
import DifferentKindsComparisonBypassCustomizations::DifferentKindsComparisonBypass
/**

View File

@@ -5,7 +5,6 @@
*/
import javascript
import semmle.javascript.security.dataflow.RemoteFlowSources
module FileAccessToHttp {
/**

View File

@@ -3,7 +3,6 @@
*/
import javascript
import semmle.javascript.security.dataflow.RemoteFlowSources
private import HttpToFileAccessCustomizations::HttpToFileAccess
/**

View File

@@ -5,7 +5,6 @@
*/
import javascript
import semmle.javascript.security.dataflow.RemoteFlowSources
import semmle.javascript.security.IncompleteBlacklistSanitizer
module IncompleteHtmlAttributeSanitization {

View File

@@ -5,7 +5,6 @@
*/
import javascript
import semmle.javascript.security.dataflow.RemoteFlowSources
module IndirectCommandInjection {
/**

View File

@@ -6,7 +6,6 @@
import javascript
private import semmle.javascript.security.SensitiveActions
private import semmle.javascript.frameworks.CryptoLibraries
module InsufficientPasswordHash {
/**

View File

@@ -5,7 +5,6 @@
*/
import javascript
import semmle.javascript.security.dataflow.RemoteFlowSources
private import semmle.javascript.dataflow.InferredTypes
module TypeConfusionThroughParameterTampering {

View File

@@ -1,7 +1,6 @@
/** DEPRECATED. Import `UnsafeDeserializationQuery` instead. */
import javascript
import semmle.javascript.security.dataflow.RemoteFlowSources
private import UnsafeDeserializationQuery as UnsafeDeserializationQuery // ignore-query-import
/** DEPRECATED. Import `UnsafeDeserializationQuery` instead. */

View File

@@ -5,7 +5,6 @@
*/
import javascript
import semmle.javascript.security.dataflow.RemoteFlowSources
module UnsafeDeserialization {
/**

View File

@@ -7,7 +7,6 @@
*/
import javascript
import semmle.javascript.security.dataflow.RemoteFlowSources
import UnsafeDeserializationCustomizations::UnsafeDeserialization
/**

View File

@@ -5,7 +5,6 @@
*/
import javascript
private import semmle.javascript.security.dataflow.RemoteFlowSources
private import semmle.javascript.PackageExports as Exports
private import semmle.javascript.dataflow.InferredTypes

View File

@@ -20,7 +20,6 @@
import javascript
import semmle.javascript.security.dataflow.PrototypePollutionQuery
import DataFlow::PathGraph
import semmle.javascript.dependencies.Dependencies
from
Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink, string moduleName,

View File

@@ -1,5 +1,4 @@
import javascript
import semmle.javascript.frameworks.CryptoLibraries
from CryptographicKey key
select key

View File

@@ -1,5 +1,4 @@
import javascript
import semmle.javascript.frameworks.CryptoLibraries
from CryptographicOperation operation
select operation, operation.getAlgorithm().getName(), operation.getInput()

View File

@@ -1,5 +1,4 @@
import javascript
import semmle.javascript.security.dataflow.RemoteFlowSources
class ExampleConfiguration extends TaintTracking::Configuration {
ExampleConfiguration() { this = "ExampleConfiguration" }

View File

@@ -1,5 +1,4 @@
import python
private import semmle.python.objects.ObjectAPI
private import semmle.python.objects.Modules
private import semmle.python.internal.CachedStages

View File

@@ -9,7 +9,6 @@
*/
import python
private import semmle.python.pointsto.Base
private import semmle.python.pointsto.PointsTo
private import semmle.python.pointsto.PointsToContext
private import semmle.python.objects.ObjectInternal

View File

@@ -4,7 +4,6 @@
*/
import python
private import semmle.python.pointsto.Base
private import semmle.python.internal.CachedStages
cached

View File

@@ -9,7 +9,6 @@
private import python
private import semmle.python.Concepts
private import semmle.python.ApiGraphs
private import semmle.python.dataflow.new.DataFlow
private import semmle.python.dataflow.new.TaintTracking
private import semmle.python.frameworks.internal.InstanceTaintStepsHelper
private import semmle.python.frameworks.Stdlib

View File

@@ -136,6 +136,7 @@ class PackageObjectInternal extends ModuleObjectInternal, TPackageObject {
/** Gets the init module of this package */
PythonModuleObjectInternal getInitModule() { result = TPythonModule(this.getSourceModule()) }
/** Holds if the folder for this package has no init module. */
predicate hasNoInitModule() {
exists(Folder f |
f = this.getFolder() and

View File

@@ -3,7 +3,6 @@ import semmle.python.types.Exceptions
private import semmle.python.pointsto.PointsTo
private import semmle.python.objects.Callables
private import semmle.python.libraries.Zope
private import semmle.python.pointsto.Base
private import semmle.python.objects.ObjectInternal
private import semmle.python.types.Builtins

View File

@@ -1,5 +1,4 @@
import python
private import semmle.python.objects.ObjectAPI
private import semmle.python.objects.ObjectInternal
private import semmle.python.types.Builtins
private import semmle.python.internal.CachedStages

View File

@@ -2,7 +2,6 @@ import python
import semmle.python.dataflow.TaintTracking
import semmle.python.web.Http
import semmle.python.web.falcon.General
import semmle.python.security.strings.External
/** https://falcon.readthedocs.io/en/stable/api/request_and_response.html */
deprecated class FalconRequest extends TaintKind {

View File

@@ -2,7 +2,6 @@ import python
import semmle.python.dataflow.TaintTracking
import semmle.python.web.Http
import semmle.python.web.falcon.General
import semmle.python.security.strings.External
/** https://falcon.readthedocs.io/en/stable/api/request_and_response.html */
deprecated class FalconResponse extends TaintKind {

View File

@@ -3,7 +3,6 @@ import semmle.python.dataflow.TaintTracking
import semmle.python.security.strings.Basic
import semmle.python.web.Http
private import semmle.python.web.pyramid.View
private import semmle.python.web.Http
/**
* A pyramid response, which is vulnerable to any sort of

View File

@@ -11,7 +11,6 @@
*/
import python
import semmle.python.SelfAttribute
import Equality
predicate class_stores_to_attribute(ClassValue cls, SelfAttributeStore store, string name) {

View File

@@ -11,7 +11,6 @@
*/
import python
import semmle.python.SelfAttribute
import ClassAttributes
predicate guarded_by_other_attribute(SelfAttributeRead a, CheckClass c) {

View File

@@ -11,7 +11,6 @@
*/
import python
import semmle.python.SelfAttribute
import ClassAttributes
predicate undefined_class_attribute(SelfAttributeRead a, CheckClass c, int line, string name) {

View File

@@ -10,7 +10,6 @@
* @id py/str-format/surplus-argument
*/
import python
import python
import AdvancedFormatting

View File

@@ -10,7 +10,6 @@
import python
import Lexical.CommentedOutCode
import python
from File f, int n
where n = count(CommentedOutCodeLine c | not c.maybeExampleCode() and c.getLocation().getFile() = f)

View File

@@ -1,7 +1,6 @@
/** Contains predicates concerning when and where files are opened and closed. */
import python
import semmle.python.GuardedControlFlow
import semmle.python.pointsto.Filters
/** Holds if `open` is a call that returns a newly opened file */

View File

@@ -1,8 +1,8 @@
private import python
private import semmle.python.Concepts
private import semmle.python.ApiGraphs
private import semmle.python.dataflow.new.DataFlow
private import semmle.python.dataflow.new.RemoteFlowSources
private import semmle.python.dataflow.new.DataFlow
/**
* A data flow source of the client ip obtained according to the remote endpoint identifier specified

View File

@@ -1,5 +1,4 @@
import python
import semmle.python.objects.ObjectAPI
from int line, ControlFlowNode f, Value v
where

View File

@@ -1,5 +1,4 @@
import python
import python
import semmle.python.pointsto.PointsTo
import semmle.python.pointsto.PointsToContext
import semmle.python.objects.ObjectInternal

View File

@@ -1,5 +1,4 @@
import python
import semmle.python.pointsto.Base
from ClassObject cls, string name
where class_declares_attribute(cls, name)

View File

@@ -1,5 +1,4 @@
import python
import semmle.python.types.Descriptors
import Util
from ClassMethodObject cm, CallNode call

View File

@@ -1,7 +1,6 @@
import python
import Util
import semmle.python.pointsto.PointsTo
import semmle.python.objects.ObjectInternal
/* This test should return _no_ results. */
predicate relevant_node(ControlFlowNode n) {

View File

@@ -1,7 +1,6 @@
import python
import Util
import semmle.python.pointsto.PointsTo
import semmle.python.objects.ObjectInternal
from ControlFlowNode f, ControlFlowNode x
where PointsTo::pointsTo(f, _, ObjectInternal::unknown(), x)

View File

@@ -1,5 +1,4 @@
import python
import semmle.python.SelfAttribute
from SelfAttributeRead sa, int line, string g, string l
where

View File

@@ -1,5 +1,4 @@
import python
import semmle.python.types.Descriptors
int lineof(Object o) { result = o.getOrigin().getLocation().getStartLine() }

View File

@@ -1,5 +1,4 @@
import python
import semmle.python.types.Descriptors
from PropertyValue p, string method_name, FunctionValue method
where

View File

@@ -1,4 +1,4 @@
WARNING: Type CommandSink has been deprecated and may be removed in future (CommandSinks.ql:5,6-17)
WARNING: Type CommandSink has been deprecated and may be removed in future (CommandSinks.ql:4,6-17)
| fabric_v1_test.py:8:7:8:28 | FabricV1Commands | externally controlled string |
| fabric_v1_test.py:9:5:9:27 | FabricV1Commands | externally controlled string |
| fabric_v1_test.py:10:6:10:38 | FabricV1Commands | externally controlled string |

View File

@@ -1,6 +1,5 @@
import python
import semmle.python.security.injection.Command
import semmle.python.security.strings.Untrusted
from CommandSink sink, TaintKind kind
where sink.sinks(kind)

View File

@@ -2,7 +2,6 @@ import python
import semmle.python.security.injection.Sql
import semmle.python.web.django.Db
import semmle.python.web.django.Model
import semmle.python.security.strings.Untrusted
from SqlInjectionSink sink, TaintKind kind
where sink.sinks(kind)

View File

@@ -0,0 +1,67 @@
import ql
Import imports(Import imp) {
(
exists(File file, TopLevel top |
imp.getResolvedModule().asFile() = file and
top.getLocation().getFile() = file and
result = top.getAMember()
)
or
exists(Module mod |
imp.getResolvedModule().asModule() = mod and
result = mod.getAMember()
)
)
}
Import getAnImport(AstNode parent) {
result = parent.(TopLevel).getAMember()
or
result = parent.(Module).getAMember()
}
pragma[inline]
predicate importsFromSameFolder(Import a, Import b) {
exists(string base |
a.getImportString().regexpCapture("(.*)\\.[^\\.]*", 1) = base and
b.getImportString().regexpCapture("(.*)\\.[^\\.]*", 1) = base
)
or
not a.getImportString().matches("%.%") and
not b.getImportString().matches("%.%")
}
predicate problem(Import imp, Import redundant, string message) {
not exists(imp.importedAs()) and
not exists(redundant.importedAs()) and
// skip the top-level language files, they have redundant imports, and that's fine.
not exists(imp.getLocation().getFile().getParentContainer().getFile("qlpack.yml")) and
// skip the DataFlowImpl.qll and similar, they have redundant imports in some copies.
not imp.getLocation()
.getFile()
.getBaseName()
.regexpMatch([".*Impl\\d?\\.qll", "DataFlowImpl.*\\.qll"]) and
// skip two imports that imports different things from the same folder.
not importsFromSameFolder(imp, redundant) and
// if the redundant is public, and the imp is private, then the redundant might add things that are exported.
not (imp.isPrivate() and not redundant.isPrivate()) and
// Actually checking if the import is redundant:
exists(AstNode parent |
imp = getAnImport(parent) and
redundant = getAnImport(parent) and
redundant.getLocation().getStartLine() > imp.getLocation().getStartLine()
|
message = "Redundant import, the module is already imported inside $@." and
// only looking for things directly imported one level down. Otherwise things gets complicated (lots of cycles).
exists(Import inner | inner = imports(imp) |
redundant.getResolvedModule() = inner.getResolvedModule() and
not inner.isPrivate() and // if the inner is private, then it's not propagated out.
not exists(inner.importedAs())
)
or
message = "Duplicate import, the module is already imported by $@." and
// two different import statements, that import the same thing
imp.getResolvedModule() = redundant.getResolvedModule()
)
}

View File

@@ -9,7 +9,6 @@
import ql
import Definitions
import codeql.IDEContextual
external string selectedSourceFile();

View File

@@ -9,7 +9,6 @@
import ql
import Definitions
import codeql.IDEContextual
external string selectedSourceFile();

View File

@@ -0,0 +1,17 @@
/**
* @name Redundant import
* @description An import that is redundant due to an earlier import
* @kind problem
* @problem.severity warning
* @id ql/redundant-import
* @tags correctness
* performance
* @precision high
*/
import ql
import codeql_ql.style.RedundantImportQuery
from Import imp, Import redundant, string message
where problem(imp, redundant, message)
select redundant, message, imp, imp.getImportString()

View File

@@ -1,6 +1,5 @@
private import codeql.ruby.AST
private import codeql.ruby.CFG
private import codeql.ruby.ast.Constant
private import internal.AST
private import internal.Constant
private import internal.Expr

Some files were not shown because too many files have changed in this diff Show More