Squish: Fix warnings

Warnings from static code checks, that is, not test.warning() at runtime.

Change-Id: I651d13491106583908059ecdb5f700f539b6d9c8
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Robert Loehning
2018-08-02 13:45:34 +02:00
parent c1f78335e0
commit ff10f8c3a5
27 changed files with 33 additions and 44 deletions

View File

@@ -37,7 +37,7 @@ def getBuildIssues():
def checkLastBuild(expectedToFail=False, createTasksFileOnError=True): def checkLastBuild(expectedToFail=False, createTasksFileOnError=True):
try: try:
# can't use waitForObject() 'cause visible is always 0 # can't use waitForObject() 'cause visible is always 0
buildProg = findObject("{type='ProjectExplorer::Internal::BuildProgress' unnamed='1' }") findObject("{type='ProjectExplorer::Internal::BuildProgress' unnamed='1' }")
except LookupError: except LookupError:
test.log("checkLastBuild called without a build") test.log("checkLastBuild called without a build")
return return

View File

@@ -24,7 +24,6 @@
############################################################################ ############################################################################
import __builtin__ import __builtin__
import operator
# for easier re-usage (because Python hasn't an enum type) # for easier re-usage (because Python hasn't an enum type)
class Targets: class Targets:

View File

@@ -23,8 +23,6 @@
# #
############################################################################ ############################################################################
import re
def handleDebuggerWarnings(config, isMsvcBuild=False): def handleDebuggerWarnings(config, isMsvcBuild=False):
if isMsvcBuild: if isMsvcBuild:
try: try:
@@ -71,7 +69,7 @@ def setBreakpointsForCurrentProject(filesAndLines):
if not filesAndLines or not isinstance(filesAndLines, (list,tuple)): if not filesAndLines or not isinstance(filesAndLines, (list,tuple)):
test.fatal("This function only takes a non-empty list/tuple holding dicts.") test.fatal("This function only takes a non-empty list/tuple holding dicts.")
return False return False
navTree = waitForObject("{type='Utils::NavigationTreeView' unnamed='1' visible='1' " waitForObject("{type='Utils::NavigationTreeView' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}") "window=':Qt Creator_Core::Internal::MainWindow'}")
for current in filesAndLines: for current in filesAndLines:
for curFile,curLine in current.iteritems(): for curFile,curLine in current.iteritems():

View File

@@ -106,7 +106,7 @@ def openContextMenuOnTextCursorPosition(editor):
# param direction is one of "Left", "Right", "Up", "Down", but "End" and combinations work as well # param direction is one of "Left", "Right", "Up", "Down", but "End" and combinations work as well
# param typeCount defines how often the cursor will be moved in the given direction (while marking) # param typeCount defines how often the cursor will be moved in the given direction (while marking)
def markText(editor, direction, typeCount=1): def markText(editor, direction, typeCount=1):
for i in range(typeCount): for _ in range(typeCount):
type(editor, "<Shift+%s>" % direction) type(editor, "<Shift+%s>" % direction)
# works for all standard editors # works for all standard editors
@@ -173,7 +173,7 @@ def verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, e
# param expectedVals a dict holding property value pairs that must match # param expectedVals a dict holding property value pairs that must match
def __handleTextTips__(textTip, expectedVals, alternativeVals): def __handleTextTips__(textTip, expectedVals, alternativeVals):
props = object.properties(textTip) props = object.properties(textTip)
expFail = altFail = False expFail = False
eResult = verifyProperties(props, expectedVals) eResult = verifyProperties(props, expectedVals)
for val in eResult.itervalues(): for val in eResult.itervalues():
if not val: if not val:
@@ -182,7 +182,6 @@ def __handleTextTips__(textTip, expectedVals, alternativeVals):
if expFail and alternativeVals != None: if expFail and alternativeVals != None:
aResult = verifyProperties(props, alternativeVals) aResult = verifyProperties(props, alternativeVals)
else: else:
altFail = True
aResult = None aResult = None
if not expFail: if not expFail:
test.passes("TextTip verified") test.passes("TextTip verified")
@@ -360,7 +359,7 @@ def invokeContextMenuItem(editorArea, command1, command2 = None):
def invokeFindUsage(editor, line, typeOperation, n=1): def invokeFindUsage(editor, line, typeOperation, n=1):
if not placeCursorToLine(editor, line, True): if not placeCursorToLine(editor, line, True):
return False return False
for i in range(n): for _ in range(n):
type(editor, typeOperation) type(editor, typeOperation)
snooze(1) snooze(1)
invokeContextMenuItem(editor, "Find Usages") invokeContextMenuItem(editor, "Find Usages")

View File

@@ -158,7 +158,7 @@ def addAndActivateKit(kit):
kitString = Targets.getStringForTarget(kit) kitString = Targets.getStringForTarget(kit)
switchViewTo(ViewConstants.PROJECTS) switchViewTo(ViewConstants.PROJECTS)
try: try:
treeView = waitForObject(":Projects.ProjectNavigationTreeView") waitForObject(":Projects.ProjectNavigationTreeView")
wanted = getQModelIndexStr("text='%s'" % kitString, bAndRIndex) wanted = getQModelIndexStr("text='%s'" % kitString, bAndRIndex)
index = findObject(wanted) index = findObject(wanted)
if str(index.toolTip).startswith(clickToActivate): if str(index.toolTip).startswith(clickToActivate):

View File

@@ -458,7 +458,7 @@ def iterateQtVersions(keepOptionsOpen=False, alreadyOnOptionsDialog=False,
currResult = additionalFunction(target, version, *argsForAdditionalFunc) currResult = additionalFunction(target, version, *argsForAdditionalFunc)
except: except:
import sys import sys
t,v,tb = sys.exc_info() t,v,_ = sys.exc_info()
currResult = None currResult = None
test.fatal("Function to additionally execute on Options Dialog could not be found or " test.fatal("Function to additionally execute on Options Dialog could not be found or "
"an exception occurred while executing it.", "%s(%s)" % (str(t), str(v))) "an exception occurred while executing it.", "%s(%s)" % (str(t), str(v)))
@@ -521,7 +521,7 @@ def iterateKits(keepOptionsOpen=False, alreadyOnOptionsDialog=False,
currResult = additionalFunction(item, kitName, *argsForAdditionalFunc) currResult = additionalFunction(item, kitName, *argsForAdditionalFunc)
except: except:
import sys import sys
t,v,tb = sys.exc_info() t,v,_ = sys.exc_info()
currResult = None currResult = None
test.fatal("Function to additionally execute on Options Dialog could not be " test.fatal("Function to additionally execute on Options Dialog could not be "
"found or an exception occurred while executing it.", "%s(%s)" % "found or an exception occurred while executing it.", "%s(%s)" %

View File

@@ -98,7 +98,7 @@ def main():
test.fail("Could not open %s.h - continuing." % className.lower()) test.fail("Could not open %s.h - continuing." % className.lower())
continue continue
editor = getEditorForFileSuffix("%s.h" % className.lower()) editor = getEditorForFileSuffix("%s.h" % className.lower())
oldContent = str(editor.plainText) str(editor.plainText)
placeCursorToLine(editor, "class %s.*" % className, True) placeCursorToLine(editor, "class %s.*" % className, True)
snooze(4) # avoid timing issue with the parser snooze(4) # avoid timing issue with the parser
invokeContextMenuItem(editor, "Refactor", "Insert Virtual Functions of Base Classes") invokeContextMenuItem(editor, "Refactor", "Insert Virtual Functions of Base Classes")

View File

@@ -70,7 +70,7 @@ def main():
openDocument("openglwindow.Sources.main\\.cpp") openDocument("openglwindow.Sources.main\\.cpp")
if not placeCursorToLine(editorWidget, 'm_posAttr = m_program->attributeLocation("posAttr");'): if not placeCursorToLine(editorWidget, 'm_posAttr = m_program->attributeLocation("posAttr");'):
return return
for i in range(13): for _ in range(13):
type(editorWidget, "<Left>") type(editorWidget, "<Left>")
type(editorWidget, "<Ctrl+Shift+u>") type(editorWidget, "<Ctrl+Shift+u>")
# wait until search finished and verify search results # wait until search finished and verify search results

View File

@@ -76,7 +76,7 @@ def main():
# select some other word in .cpp file and select "Edit" -> "Find/Replace". # select some other word in .cpp file and select "Edit" -> "Find/Replace".
clickButton(waitForObject(":Qt Creator.CloseFind_QToolButton")) clickButton(waitForObject(":Qt Creator.CloseFind_QToolButton"))
placeCursorToLine(editorWidget, "void Trianglefind::render()") placeCursorToLine(editorWidget, "void Trianglefind::render()")
for i in range(10): for _ in range(10):
type(editorWidget, "<Left>") type(editorWidget, "<Left>")
markText(editorWidget, "Left", 12) markText(editorWidget, "Left", 12)
invokeMenuItem("Edit", "Find/Replace", "Find/Replace") invokeMenuItem("Edit", "Find/Replace", "Find/Replace")

View File

@@ -107,7 +107,7 @@ def main():
checkIfObjectExists(manualQModelIndex, verboseOnFail = True), checkIfObjectExists(manualQModelIndex, verboseOnFail = True),
"Verifying if all folders and bookmarks are present") "Verifying if all folders and bookmarks are present")
mouseClick(waitForObject(":Qt Creator_Bookmarks_TreeView"), 5, 5, 0, Qt.LeftButton) mouseClick(waitForObject(":Qt Creator_Bookmarks_TreeView"), 5, 5, 0, Qt.LeftButton)
for i in range(6): for _ in range(6):
type(waitForObject(":Qt Creator_Bookmarks_TreeView"), "<Right>") type(waitForObject(":Qt Creator_Bookmarks_TreeView"), "<Right>")
type(waitForObject(":Qt Creator_Bookmarks_TreeView"), "<Return>") type(waitForObject(":Qt Creator_Bookmarks_TreeView"), "<Return>")
test.verify(textForQtVersion("Building and Running an Example") in getHelpTitle(), test.verify(textForQtVersion("Building and Running an Example") in getHelpTitle(),

View File

@@ -48,7 +48,7 @@ def main():
"Verifying if error is properly reported") "Verifying if error is properly reported")
# repair error - go to written line # repair error - go to written line
placeCursorToLine(editorArea, testingCodeLine) placeCursorToLine(editorArea, testingCodeLine)
for i in range(14): for _ in range(14):
type(editorArea, "<Left>") type(editorArea, "<Left>")
markText(editorArea, "Right") markText(editorArea, "Right")
type(editorArea, "c") type(editorArea, "c")

View File

@@ -90,7 +90,7 @@ def main():
if not placeCursorToLine(editorArea, "Rectangle {"): if not placeCursorToLine(editorArea, "Rectangle {"):
invokeMenuItem("File", "Exit") invokeMenuItem("File", "Exit")
return return
for i in range(5): for _ in range(5):
type(editorArea, "<Left>") type(editorArea, "<Left>")
invokeContextMenuItem(editorArea, "Find Usages") invokeContextMenuItem(editorArea, "Find Usages")
# check if usage was properly found # check if usage was properly found
@@ -109,7 +109,7 @@ def main():
if not placeCursorToLine(editorArea, "anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter }"): if not placeCursorToLine(editorArea, "anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter }"):
invokeMenuItem("File", "Exit") invokeMenuItem("File", "Exit")
return return
for i in range(87): for _ in range(87):
type(editorArea, "<Left>") type(editorArea, "<Left>")
invokeMenuItem("Tools", "QML/JS", "Find Usages") invokeMenuItem("Tools", "QML/JS", "Find Usages")
# check if usage was properly found # check if usage was properly found
@@ -128,7 +128,7 @@ def main():
if not placeCursorToLine(editorArea, "SequentialAnimation on opacity {"): if not placeCursorToLine(editorArea, "SequentialAnimation on opacity {"):
invokeMenuItem("File", "Exit") invokeMenuItem("File", "Exit")
return return
for i in range(5): for _ in range(5):
type(editorArea, "<Left>") type(editorArea, "<Left>")
type(editorArea, "<Ctrl+Shift+u>") type(editorArea, "<Ctrl+Shift+u>")
# check if usage was properly found # check if usage was properly found

View File

@@ -37,7 +37,7 @@ def main():
saveAndExit() saveAndExit()
return return
placeCursorToLine(editorArea, "TextEdit {") placeCursorToLine(editorArea, "TextEdit {")
for i in range(5): for _ in range(5):
type(editorArea, "<Left>") type(editorArea, "<Left>")
# invoke Refactoring - Move Component into separate file # invoke Refactoring - Move Component into separate file
invokeContextMenuItem(editorArea, "Refactoring", "Move Component into Separate File") invokeContextMenuItem(editorArea, "Refactoring", "Move Component into Separate File")

View File

@@ -32,13 +32,13 @@ def main():
homeKey = "<Home>" homeKey = "<Home>"
if platform.system() == "Darwin": if platform.system() == "Darwin":
homeKey = "<Ctrl+Left>" homeKey = "<Ctrl+Left>"
for i in range(2): for _ in range(2):
type(editorArea, homeKey) type(editorArea, homeKey)
type(editorArea, "<Return>") type(editorArea, "<Return>")
type(editorArea, "<Up>") type(editorArea, "<Up>")
type(editorArea, "<Tab>") type(editorArea, "<Tab>")
type(editorArea, "Item { x: 10; y: 20; width: 10 }") type(editorArea, "Item { x: 10; y: 20; width: 10 }")
for i in range(30): for _ in range(30):
type(editorArea, "<Left>") type(editorArea, "<Left>")
invokeMenuItem("File", "Save All") invokeMenuItem("File", "Save All")
# activate menu and apply 'Refactoring - Split initializer' # activate menu and apply 'Refactoring - Split initializer'

View File

@@ -32,14 +32,14 @@ def main():
homeKey = "<Home>" homeKey = "<Home>"
if platform.system() == "Darwin": if platform.system() == "Darwin":
homeKey = "<Ctrl+Left>" homeKey = "<Ctrl+Left>"
for i in range(2): for _ in range(2):
type(editorArea, homeKey) type(editorArea, homeKey)
type(editorArea, "<Return>") type(editorArea, "<Return>")
type(editorArea, "<Up>") type(editorArea, "<Up>")
type(editorArea, "<Tab>") type(editorArea, "<Tab>")
testingItemText = "Item { x: 10; y: 20; width: 10 }" testingItemText = "Item { x: 10; y: 20; width: 10 }"
type(editorArea, testingItemText) type(editorArea, testingItemText)
for i in range(30): for _ in range(30):
type(editorArea, "<Left>") type(editorArea, "<Left>")
invokeMenuItem("File", "Save All") invokeMenuItem("File", "Save All")
# invoke Refactoring - Wrap Component in Loader # invoke Refactoring - Wrap Component in Loader

View File

@@ -31,7 +31,7 @@ def main():
return return
type(editorArea, "<Return>") type(editorArea, "<Return>")
type(editorArea, "Color") type(editorArea, "Color")
for i in range(3): for _ in range(3):
type(editorArea, "<Left>") type(editorArea, "<Left>")
invokeMenuItem("File", "Save All") invokeMenuItem("File", "Save All")
# invoke Refactoring - Add a message suppression comment. # invoke Refactoring - Add a message suppression comment.

View File

@@ -71,7 +71,7 @@ def main():
return return
# cancel indentation # cancel indentation
type(editorArea, "<Ctrl+a>") type(editorArea, "<Ctrl+a>")
for i in range(5): for _ in range(5):
type(editorArea, "<Shift+Backtab>") type(editorArea, "<Shift+Backtab>")
# select unindented block # select unindented block
type(editorArea, "<Ctrl+a>") type(editorArea, "<Ctrl+a>")

View File

@@ -68,7 +68,6 @@ def debuggerHasStopped():
def getQmlJSConsoleOutput(): def getQmlJSConsoleOutput():
try: try:
result = []
consoleView = waitForObject(":DebugModeWidget_Debugger::Internal::ConsoleView") consoleView = waitForObject(":DebugModeWidget_Debugger::Internal::ConsoleView")
model = consoleView.model() model = consoleView.model()
# old input, output, new input > 2 # old input, output, new input > 2
@@ -135,7 +134,7 @@ def main():
switchViewTo(ViewConstants.EDIT) switchViewTo(ViewConstants.EDIT)
# start debugging # start debugging
clickButton(fancyDebugButton) clickButton(fancyDebugButton)
locAndExprTV = waitForObject(":Locals and Expressions_Debugger::Internal::WatchTreeView") waitForObject(":Locals and Expressions_Debugger::Internal::WatchTreeView")
rootIndex = getQModelIndexStr("text='Rectangle'", rootIndex = getQModelIndexStr("text='Rectangle'",
":Locals and Expressions_Debugger::Internal::WatchTreeView") ":Locals and Expressions_Debugger::Internal::WatchTreeView")
# make sure the items inside the root item are visible # make sure the items inside the root item are visible

View File

@@ -44,7 +44,6 @@ def prepareQmlFile():
editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget") editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
isDarwin = platform.system() == 'Darwin' isDarwin = platform.system() == 'Darwin'
for i in range(3): for i in range(3):
content = "%s" % editor.plainText
if not placeCursorToLine(editor, 'title: qsTr("Hello World")'): if not placeCursorToLine(editor, 'title: qsTr("Hello World")'):
test.fatal("Couldn't find line(s) I'm looking for - QML file seems to " test.fatal("Couldn't find line(s) I'm looking for - QML file seems to "
"have changed!\nLeaving test...") "have changed!\nLeaving test...")

View File

@@ -118,7 +118,7 @@ def testRenameMacroAfterSourceMoving():
return True return True
def performMacroRenaming(newMacroName): def performMacroRenaming(newMacroName):
for i in range(10): for _ in range(10):
type(cppEditorStr, "<Left>") type(cppEditorStr, "<Left>")
invokeContextMenuItem(waitForObject(cppEditorStr), "Refactor", invokeContextMenuItem(waitForObject(cppEditorStr), "Refactor",
"Rename Symbol Under Cursor") "Rename Symbol Under Cursor")

View File

@@ -24,7 +24,6 @@
############################################################################ ############################################################################
source("../../shared/qtcreator.py") source("../../shared/qtcreator.py")
import re
SpeedCrunchPath = "" SpeedCrunchPath = ""

View File

@@ -45,7 +45,6 @@ def main():
projects = catModel.index(0, 0) projects = catModel.index(0, 0)
test.compare("Projects", str(projects.data())) test.compare("Projects", str(projects.data()))
comboBox = findObject(":New.comboBox_QComboBox") comboBox = findObject(":New.comboBox_QComboBox")
targets = zip(*kits.values())[0]
test.verify(comboBox.enabled, "Verifying whether combobox is enabled.") test.verify(comboBox.enabled, "Verifying whether combobox is enabled.")
test.compare(comboBox.currentText, "All Templates") test.compare(comboBox.currentText, "All Templates")
try: try:

View File

@@ -26,8 +26,6 @@
source("../../shared/qtcreator.py") source("../../shared/qtcreator.py")
import re import re
import tempfile
import __builtin__
currentSelectedTreeItem = None currentSelectedTreeItem = None
warningOrError = re.compile('<p><b>((Error|Warning).*?)</p>') warningOrError = re.compile('<p><b>((Error|Warning).*?)</p>')

View File

@@ -34,7 +34,6 @@ def main():
for qtVersion, controls in available: for qtVersion, controls in available:
targ = [Targets.DESKTOP_5_6_1_DEFAULT] targ = [Targets.DESKTOP_5_6_1_DEFAULT]
quick = "2.6"
# using a temporary directory won't mess up a potentially existing # using a temporary directory won't mess up a potentially existing
workingDir = tempDir() workingDir = tempDir()
checkedTargets = createNewQtQuickApplication(workingDir, targets=targ, checkedTargets = createNewQtQuickApplication(workingDir, targets=targ,

View File

@@ -92,7 +92,7 @@ def __clickCommit__(count):
test.fail("Could not find the %d. commit - leaving test" % count) test.fail("Could not find the %d. commit - leaving test" % count)
return False return False
placeCursorToLine(gitEditor, line) placeCursorToLine(gitEditor, line)
for i in range(30): for _ in range(30):
type(gitEditor, "<Left>") type(gitEditor, "<Left>")
# get the current cursor rectangle which should be positioned on the commit ID # get the current cursor rectangle which should be positioned on the commit ID
rect = gitEditor.cursorRect() rect = gitEditor.cursorRect()
@@ -234,7 +234,7 @@ def deleteProject():
if os.path.exists(path): if os.path.exists(path):
try: try:
# Make files in .git writable to remove them # Make files in .git writable to remove them
for root, dirs, files in os.walk(path): for root, _, files in os.walk(path):
for name in files: for name in files:
os.chmod(os.path.join(root, name), stat.S_IWUSR) os.chmod(os.path.join(root, name), stat.S_IWUSR)
shutil.rmtree(path) shutil.rmtree(path)