# eric6.Plugins.CheckerPlugins.CodeStyleChecker.CodeStyleCheckerDialog

Module implementing a dialog to show the results of the code style check.

### Global Attributes

None

### Classes

CodeStyleCheckerDialog | Class implementing a dialog to show the results of the code style check.

### Functions

None

## CodeStyleCheckerDialog

Class implementing a dialog to show the results of the code style check.

### Derived from

QDialog, Ui_CodeStyleCheckerDialog

### Class Attributes

availableFutures
codeRole
filenameRole
fixableRole
hasResults
ignoredRole
lineRole
messageRole
noFiles
noResults
positionRole

### Class Methods

None

### Methods

CodeStyleCheckerDialog | Constructor
__batchFinished | Private slot handling the completion of a batch job.
__clearErrors | Private method to clear all warning markers of open editors to be checked.
__createErrorItem | Private slot to create a new error item in the result list.
__createResultItem | Private method to create an entry in the result list.
__finish | Private slot called when the code style check finished or the user pressed the cancel button.
__getBuiltinsIgnoreList | Private method to get a dictionary containing the builtins assignments to be ignored.
__getEol | Private method to get the applicable eol string.
__getSelectedFixableItems | Private method to extract all selected items for fixable issues.
__getSelectedFutureImports | Private method to get the expected future imports.
__initBuiltinsIgnoreList | Private method to populate the list of shadowed builtins to be ignored.
__initFuturesList | Private method to set the selected status of the future imports.
__itemFixable | Private method to check, if an item has a fixable issue.
__modifyFixedResultItem | Private method to modify a result list entry to show its positive fixed state.
__modifyOptions | Private method to modify the options based on eflag: entries.
__processError | Private slot to process an error indication from the service.
__processResult | Private slot called after perfoming a style check on one file.
__resetStatistics | Private slot to reset the statistics data.
__resort | Private method to resort the tree.
__selectCodes | Private method to select message codes via a selection dialog.
__updateFixerStatistics | Private method to update the collected fixer related statistics.
__updateStatistics | Private method to update the collected statistics.
check | Public method to start a style check for one file.
checkBatch | Public method to start a style check batch job.
on_addBuiltinButton_clicked | Private slot to add a built-in assignment to be ignored.
on_builtinsAssignmentList_itemSelectionChanged | Private slot to react upon changes of the selected builtin assignments.
on_buttonBox_clicked | Private slot called by a button of the button box clicked.
on_deleteBuiltinButton_clicked | Private slot to delete the selected items from the list.
on_excludeMessagesSelectButton_clicked | Private slot to select the message codes to be excluded via a selection dialog.
on_fixButton_clicked | Private slot to fix selected issues.
on_fixIssuesSelectButton_clicked | Private slot to select the issue codes to be fixed via a selection dialog.
on_includeMessagesSelectButton_clicked | Private slot to select the message codes to be included via a selection dialog.
on_loadDefaultButton_clicked | Private slot to load the default configuration values.
on_noFixIssuesSelectButton_clicked | Private slot to select the issue codes not to be fixed via a selection dialog.
on_resetDefaultButton_clicked | Private slot to reset the configuration values to their default values.
on_resultList_itemActivated | Private slot to handle the activation of an item.
on_resultList_itemSelectionChanged | Private slot to change the dialog state depending on the selection.
on_showButton_clicked | Private slot to handle the "Show" button press.
on_startButton_clicked | Private slot to start a code style check run.
on_statisticsButton_clicked | Private slot to show the statistics dialog.
on_storeDefaultButton_clicked | Private slot to store the current configuration values as default values.
prepare | Public method to prepare the dialog with a list of filenames.
start | Public slot to start the code style check.

### Static Methods

None

#### CodeStyleCheckerDialog (Constructor)

CodeStyleCheckerDialog(styleCheckService, parent=None)

Constructor

styleCheckService
  reference to the service (CodeStyleCheckService)
parent
  reference to the parent widget (QWidget)

#### CodeStyleCheckerDialog.__batchFinished

__batchFinished()

Private slot handling the completion of a batch job.

#### CodeStyleCheckerDialog.__clearErrors

__clearErrors(files)

Private method to clear all warning markers of open editors to be checked.

files
  list of files to be checked (list of string)

#### CodeStyleCheckerDialog.__createErrorItem

__createErrorItem(filename, message)

Private slot to create a new error item in the result list.

filename (str)
  name of the file
message (str)
  error message

#### CodeStyleCheckerDialog.__createResultItem

__createResultItem(filename, line, pos, message, fixed, autofixing, ignored)

Private method to create an entry in the result list.

filename
  file name of the file (string)
line
  line number of issue (integer or string)
pos
  character position of issue (integer or string)
message
  message text (string)
fixed
  flag indicating a fixed issue (boolean)
autofixing
  flag indicating, that we are fixing issues automatically (boolean)
ignored
  flag indicating an ignored issue (boolean)

Returns:
  reference to the created item (QTreeWidgetItem)

#### CodeStyleCheckerDialog.__finish

__finish()

Private slot called when the code style check finished or the user pressed the cancel button.

#### CodeStyleCheckerDialog.__getBuiltinsIgnoreList

__getBuiltinsIgnoreList()

Private method to get a dictionary containing the builtins assignments to be ignored.

Returns:
  dictionary containing the builtins assignments to be ignored

Return Type:
  dict of list of str

#### CodeStyleCheckerDialog.__getEol

__getEol(fn)

Private method to get the applicable eol string.

fn
  filename where to determine the line ending (str)

Returns:
  eol string (string)

#### CodeStyleCheckerDialog.__getSelectedFixableItems

__getSelectedFixableItems()

Private method to extract all selected items for fixable issues.

Returns:
  selected items for fixable issues (list of QTreeWidgetItem)

#### CodeStyleCheckerDialog.__getSelectedFutureImports

__getSelectedFutureImports()

Private method to get the expected future imports.

Returns:
  expected future imports as a comma separated string

Return Type:
  str

#### CodeStyleCheckerDialog.__initBuiltinsIgnoreList

__initBuiltinsIgnoreList(builtinsIgnoreDict)

Private method to populate the list of shadowed builtins to be ignored.

builtinsIgnoreDict (dict of list of str)
  dictionary containing the builtins assignments to be ignored

#### CodeStyleCheckerDialog.__initFuturesList

__initFuturesList(selectedFutures)

Private method to set the selected status of the future imports.

selectedFutures (str)
  comma separated list of expected future imports

#### CodeStyleCheckerDialog.__itemFixable

__itemFixable(itm)

Private method to check, if an item has a fixable issue.

itm
  item to be checked (QTreeWidgetItem)

Returns:
  flag indicating a fixable issue (boolean)

#### CodeStyleCheckerDialog.__modifyFixedResultItem

__modifyFixedResultItem(itm, text, fixed)

Private method to modify a result list entry to show its positive fixed state.

itm
  reference to the item to modify (QTreeWidgetItem)
text
  text to be appended (string)
fixed
  flag indicating a fixed issue (boolean)

#### CodeStyleCheckerDialog.__modifyOptions

__modifyOptions(source)

Private method to modify the options based on eflag: entries.

This method looks for comment lines like '# eflag: noqa = M601' at the end of the source in order to extend the list of excluded messages for one file only.

source
  source text (list of str or str)

Returns:
  list of checker options

#### CodeStyleCheckerDialog.__processError

__processError(fn, msg)

Private slot to process an error indication from the service.

fn (str)
  filename of the file
msg (str)
  error message

#### CodeStyleCheckerDialog.__processResult

__processResult(fn, codeStyleCheckerStats, fixes, results)

Private slot called after perfoming a style check on one file.

fn
  filename of the just checked file (str)
codeStyleCheckerStats
  stats of style and name check (dict)
fixes
  number of applied fixes (int)
results
  tuple for each found violation of style (tuple of lineno (int), position (int), text (str), ignored (bool), fixed (bool), autofixing (bool))

#### CodeStyleCheckerDialog.__resetStatistics

__resetStatistics()

Private slot to reset the statistics data.

#### CodeStyleCheckerDialog.__resort

__resort()

Private method to resort the tree.

#### CodeStyleCheckerDialog.__selectCodes

__selectCodes(edit, showFixCodes)

Private method to select message codes via a selection dialog.

edit
  reference of the line edit to be populated (QLineEdit)
showFixCodes
  flag indicating to show a list of fixable issues (boolean)

#### CodeStyleCheckerDialog.__updateFixerStatistics

__updateFixerStatistics(fixer)

Private method to update the collected fixer related statistics.

fixer
  reference to the code style fixer (CodeStyleFixer)

#### CodeStyleCheckerDialog.__updateStatistics

__updateStatistics(statistics, fixer, ignoredErrors)

Private method to update the collected statistics.

statistics
  dictionary of statistical data with message code as key and message count as value
fixer
  reference to the code style fixer (CodeStyleFixer)
ignoredErrors
  number of ignored errors (integer)

#### CodeStyleCheckerDialog.check

check(codestring='')

Public method to start a style check for one file.

The results are reported to the __processResult slot.

codestring=
  optional sourcestring (str)

#### CodeStyleCheckerDialog.checkBatch

checkBatch()

Public method to start a style check batch job.

The results are reported to the __processResult slot.

#### CodeStyleCheckerDialog.on_addBuiltinButton_clicked

on_addBuiltinButton_clicked()

Private slot to add a built-in assignment to be ignored.

#### CodeStyleCheckerDialog.on_builtinsAssignmentList_itemSelectionChanged

on_builtinsAssignmentList_itemSelectionChanged()

Private slot to react upon changes of the selected builtin assignments.

#### CodeStyleCheckerDialog.on_buttonBox_clicked

on_buttonBox_clicked(button)

Private slot called by a button of the button box clicked.

button
  button that was clicked (QAbstractButton)

#### CodeStyleCheckerDialog.on_deleteBuiltinButton_clicked

on_deleteBuiltinButton_clicked()

Private slot to delete the selected items from the list.

#### CodeStyleCheckerDialog.on_excludeMessagesSelectButton_clicked

on_excludeMessagesSelectButton_clicked()

Private slot to select the message codes to be excluded via a selection dialog.

#### CodeStyleCheckerDialog.on_fixButton_clicked

on_fixButton_clicked()

Private slot to fix selected issues.

Build a dictionary of issues to fix. Update the initialized __options. Then call check with the dict as keyparam to fix selected issues.

#### CodeStyleCheckerDialog.on_fixIssuesSelectButton_clicked

on_fixIssuesSelectButton_clicked()

Private slot to select the issue codes to be fixed via a selection dialog.

#### CodeStyleCheckerDialog.on_includeMessagesSelectButton_clicked

on_includeMessagesSelectButton_clicked()

Private slot to select the message codes to be included via a selection dialog.

#### CodeStyleCheckerDialog.on_loadDefaultButton_clicked

on_loadDefaultButton_clicked()

Private slot to load the default configuration values.

#### CodeStyleCheckerDialog.on_noFixIssuesSelectButton_clicked

on_noFixIssuesSelectButton_clicked()

Private slot to select the issue codes not to be fixed via a selection dialog.

#### CodeStyleCheckerDialog.on_resetDefaultButton_clicked

on_resetDefaultButton_clicked()

Private slot to reset the configuration values to their default values.

#### CodeStyleCheckerDialog.on_resultList_itemActivated

on_resultList_itemActivated(item, column)

Private slot to handle the activation of an item.

item
  reference to the activated item (QTreeWidgetItem)
column
  column the item was activated in (integer)

#### CodeStyleCheckerDialog.on_resultList_itemSelectionChanged

on_resultList_itemSelectionChanged()

Private slot to change the dialog state depending on the selection.

#### CodeStyleCheckerDialog.on_showButton_clicked

on_showButton_clicked()

Private slot to handle the "Show" button press.

#### CodeStyleCheckerDialog.on_startButton_clicked

on_startButton_clicked()

Private slot to start a code style check run.

#### CodeStyleCheckerDialog.on_statisticsButton_clicked

on_statisticsButton_clicked()

Private slot to show the statistics dialog.

#### CodeStyleCheckerDialog.on_storeDefaultButton_clicked

on_storeDefaultButton_clicked()

Private slot to store the current configuration values as default values.

#### CodeStyleCheckerDialog.prepare

prepare(fileList, project)

Public method to prepare the dialog with a list of filenames.

fileList
  list of filenames (list of strings)
project
  reference to the project object (Project)

#### CodeStyleCheckerDialog.start

start(fn, save=False, repeat=None)

Public slot to start the code style check.

fn
  file or list of files or directory to be checked (string or list of strings)
save=
  flag indicating to save the given file/file list/directory (boolean)
repeat=
  state of the repeat check box if it is not None (None or boolean)

Up