542 str(SecurityDefaults["weak_key_size_ec_high"]), |
542 str(SecurityDefaults["weak_key_size_ec_high"]), |
543 "WeakKeySizeEcMedium": |
543 "WeakKeySizeEcMedium": |
544 str(SecurityDefaults["weak_key_size_ec_medium"]), |
544 str(SecurityDefaults["weak_key_size_ec_medium"]), |
545 "CheckTypedException": |
545 "CheckTypedException": |
546 SecurityDefaults["check_typed_exception"], |
546 SecurityDefaults["check_typed_exception"], |
|
547 } |
|
548 |
|
549 if "ImportsChecker" not in self.__data: |
|
550 self.__data["ImportsChecker"] = { |
|
551 "ApplicationModuleNames": [], |
547 } |
552 } |
548 |
553 |
549 self.__initCategoriesList(self.__data["EnabledCheckerCategories"]) |
554 self.__initCategoriesList(self.__data["EnabledCheckerCategories"]) |
550 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) |
555 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) |
551 self.excludeMessagesEdit.setText(self.__data["ExcludeMessages"]) |
556 self.excludeMessagesEdit.setText(self.__data["ExcludeMessages"]) |
805 int(self.ecMediumRiskCombo.currentText()), |
810 int(self.ecMediumRiskCombo.currentText()), |
806 "check_typed_exception": |
811 "check_typed_exception": |
807 self.typedExceptionsCheckBox.isChecked(), |
812 self.typedExceptionsCheckBox.isChecked(), |
808 } |
813 } |
809 |
814 |
|
815 importsArgs = { |
|
816 "ApplicationModuleNames": |
|
817 sorted(self.appModulesEdit.toPlainText().split()), |
|
818 } |
|
819 |
810 self.__options = [excludeMessages, includeMessages, repeatMessages, |
820 self.__options = [excludeMessages, includeMessages, repeatMessages, |
811 fixCodes, noFixCodes, fixIssues, maxLineLength, |
821 fixCodes, noFixCodes, fixIssues, maxLineLength, |
812 maxDocLineLength, blankLines, hangClosing, |
822 maxDocLineLength, blankLines, hangClosing, |
813 docType, codeComplexityArgs, miscellaneousArgs, |
823 docType, codeComplexityArgs, miscellaneousArgs, |
814 annotationArgs, securityArgs] |
824 annotationArgs, securityArgs, importsArgs] |
815 |
825 |
816 # now go through all the files |
826 # now go through all the files |
817 self.progress = 0 |
827 self.progress = 0 |
818 self.files.sort() |
828 self.files.sort() |
819 if len(self.files) == 1: |
829 if len(self.files) == 1: |
1237 "WeakKeySizeEcMedium": |
1247 "WeakKeySizeEcMedium": |
1238 self.ecMediumRiskCombo.currentText(), |
1248 self.ecMediumRiskCombo.currentText(), |
1239 "CheckTypedException": |
1249 "CheckTypedException": |
1240 self.typedExceptionsCheckBox.isChecked(), |
1250 self.typedExceptionsCheckBox.isChecked(), |
1241 }, |
1251 }, |
|
1252 "ImportsChecker": { |
|
1253 "ApplicationModuleNames": |
|
1254 sorted(self.appModulesEdit.toPlainText().split()) |
|
1255 }, |
1242 } |
1256 } |
1243 if ( |
1257 if ( |
1244 json.dumps(data, sort_keys=True) != |
1258 json.dumps(data, sort_keys=True) != |
1245 json.dumps(self.__data, sort_keys=True) |
1259 json.dumps(self.__data, sort_keys=True) |
1246 ): |
1260 ): |
1494 MiscellaneousCheckerDefaultArgs[ |
1508 MiscellaneousCheckerDefaultArgs[ |
1495 "CommentedCodeChecker"]["WhiteList"] |
1509 "CommentedCodeChecker"]["WhiteList"] |
1496 ) |
1510 ) |
1497 )) |
1511 )) |
1498 |
1512 |
1499 # type annotations |
1513 # Type Annotations Checker |
1500 self.minAnnotationsCoverageSpinBox.setValue(int( |
1514 self.minAnnotationsCoverageSpinBox.setValue(int( |
1501 Preferences.getSettings().value( |
1515 Preferences.getSettings().value( |
1502 "PEP8/MinimumAnnotationsCoverage", |
1516 "PEP8/MinimumAnnotationsCoverage", |
1503 AnnotationsCheckerDefaultArgs["MinimumCoverage"]))) |
1517 AnnotationsCheckerDefaultArgs["MinimumCoverage"]))) |
1504 self.maxAnnotationsComplexitySpinBox.setValue(int( |
1518 self.maxAnnotationsComplexitySpinBox.setValue(int( |
1536 self.overloadDecoratorEdit.setText(", ".join(Preferences.toList( |
1550 self.overloadDecoratorEdit.setText(", ".join(Preferences.toList( |
1537 Preferences.getSettings().value( |
1551 Preferences.getSettings().value( |
1538 "PEP8/OverloadDecorators", |
1552 "PEP8/OverloadDecorators", |
1539 AnnotationsCheckerDefaultArgs["OverloadDecorators"])))) |
1553 AnnotationsCheckerDefaultArgs["OverloadDecorators"])))) |
1540 |
1554 |
1541 # security |
1555 # Security Checker |
1542 from .Security.SecurityDefaults import SecurityDefaults |
1556 from .Security.SecurityDefaults import SecurityDefaults |
1543 self.tmpDirectoriesEdit.setPlainText("\n".join( |
1557 self.tmpDirectoriesEdit.setPlainText("\n".join( |
1544 Preferences.toList(Preferences.getSettings().value( |
1558 Preferences.toList(Preferences.getSettings().value( |
1545 "PEP8/HardcodedTmpDirectories", |
1559 "PEP8/HardcodedTmpDirectories", |
1546 SecurityDefaults["hardcoded_tmp_directories"])))) |
1560 SecurityDefaults["hardcoded_tmp_directories"])))) |
1579 self.typedExceptionsCheckBox.setChecked(Preferences.toBool( |
1593 self.typedExceptionsCheckBox.setChecked(Preferences.toBool( |
1580 Preferences.getSettings().value( |
1594 Preferences.getSettings().value( |
1581 "PEP8/CheckTypedException", |
1595 "PEP8/CheckTypedException", |
1582 SecurityDefaults["check_typed_exception"]))), |
1596 SecurityDefaults["check_typed_exception"]))), |
1583 |
1597 |
|
1598 # Imports Checker |
|
1599 self.appModulesEdit.setPlainText(" ".join( |
|
1600 sorted(Preferences.toList(Preferences.getSettings().value( |
|
1601 "PEP8/ApplicationModuleNames", []))))) |
|
1602 |
1584 self.__cleanupData() |
1603 self.__cleanupData() |
1585 |
1604 |
1586 @pyqtSlot() |
1605 @pyqtSlot() |
1587 def on_storeDefaultButton_clicked(self): |
1606 def on_storeDefaultButton_clicked(self): |
1588 """ |
1607 """ |
1643 "PEP8/AggressiveSearch", self.aggressiveCheckBox.isChecked()) |
1662 "PEP8/AggressiveSearch", self.aggressiveCheckBox.isChecked()) |
1644 Preferences.getSettings().setValue( |
1663 Preferences.getSettings().setValue( |
1645 "PEP8/CommentedCodeWhitelist", |
1664 "PEP8/CommentedCodeWhitelist", |
1646 self.__getCommentedCodeCheckerWhiteList()) |
1665 self.__getCommentedCodeCheckerWhiteList()) |
1647 |
1666 |
1648 # type annotations |
1667 # Type Annotations Checker |
1649 Preferences.getSettings().setValue( |
1668 Preferences.getSettings().setValue( |
1650 "PEP8/MinimumAnnotationsCoverage", |
1669 "PEP8/MinimumAnnotationsCoverage", |
1651 self.minAnnotationsCoverageSpinBox.value()) |
1670 self.minAnnotationsCoverageSpinBox.value()) |
1652 Preferences.getSettings().setValue( |
1671 Preferences.getSettings().setValue( |
1653 "PEP8/MaximumAnnotationComplexity", |
1672 "PEP8/MaximumAnnotationComplexity", |
1677 Preferences.getSettings().setValue( |
1696 Preferences.getSettings().setValue( |
1678 "PEP8/OverloadDecorators", |
1697 "PEP8/OverloadDecorators", |
1679 [d.strip() |
1698 [d.strip() |
1680 for d in self.overloadDecoratorEdit.text().split(",")]) |
1699 for d in self.overloadDecoratorEdit.text().split(",")]) |
1681 |
1700 |
1682 # security |
1701 # Security Checker |
1683 Preferences.getSettings().setValue( |
1702 Preferences.getSettings().setValue( |
1684 "PEP8/HardcodedTmpDirectories", |
1703 "PEP8/HardcodedTmpDirectories", |
1685 [t.strip() |
1704 [t.strip() |
1686 for t in self.tmpDirectoriesEdit.toPlainText().splitlines() |
1705 for t in self.tmpDirectoriesEdit.toPlainText().splitlines() |
1687 ]), |
1706 ]), |
1714 "PEP8/WeakKeySizeEcMedium", |
1733 "PEP8/WeakKeySizeEcMedium", |
1715 self.ecMediumRiskCombo.currentText()), |
1734 self.ecMediumRiskCombo.currentText()), |
1716 Preferences.getSettings().setValue( |
1735 Preferences.getSettings().setValue( |
1717 "PEP8/CheckTypedException", |
1736 "PEP8/CheckTypedException", |
1718 self.typedExceptionsCheckBox.isChecked()), |
1737 self.typedExceptionsCheckBox.isChecked()), |
|
1738 |
|
1739 # Imports Checker |
|
1740 Preferences.getSettings().setValue( |
|
1741 "PEP8/ApplicationModuleNames", |
|
1742 sorted(self.appModulesEdit.toPlainText().split())) |
1719 |
1743 |
1720 @pyqtSlot() |
1744 @pyqtSlot() |
1721 def on_resetDefaultButton_clicked(self): |
1745 def on_resetDefaultButton_clicked(self): |
1722 """ |
1746 """ |
1723 Private slot to reset the configuration values to their default values. |
1747 Private slot to reset the configuration values to their default values. |
1774 "PEP8/CommentedCodeWhitelist", |
1798 "PEP8/CommentedCodeWhitelist", |
1775 MiscellaneousCheckerDefaultArgs[ |
1799 MiscellaneousCheckerDefaultArgs[ |
1776 "CommentedCodeChecker"]["WhiteList"] |
1800 "CommentedCodeChecker"]["WhiteList"] |
1777 ) |
1801 ) |
1778 |
1802 |
1779 # type annotations |
1803 # Type Annotations Checker |
1780 Preferences.getSettings().setValue( |
1804 Preferences.getSettings().setValue( |
1781 "PEP8/MinimumAnnotationsCoverage", |
1805 "PEP8/MinimumAnnotationsCoverage", |
1782 AnnotationsCheckerDefaultArgs["MinimumCoverage"]) |
1806 AnnotationsCheckerDefaultArgs["MinimumCoverage"]) |
1783 Preferences.getSettings().setValue( |
1807 Preferences.getSettings().setValue( |
1784 "PEP8/MaximumAnnotationComplexity", |
1808 "PEP8/MaximumAnnotationComplexity", |
1806 AnnotationsCheckerDefaultArgs["DispatchDecorators"]) |
1830 AnnotationsCheckerDefaultArgs["DispatchDecorators"]) |
1807 Preferences.getSettings().setValue( |
1831 Preferences.getSettings().setValue( |
1808 "PEP8/OverloadDecorators", |
1832 "PEP8/OverloadDecorators", |
1809 AnnotationsCheckerDefaultArgs["OverloadDecorators"]) |
1833 AnnotationsCheckerDefaultArgs["OverloadDecorators"]) |
1810 |
1834 |
1811 # security |
1835 # Security Checker |
1812 from .Security.SecurityDefaults import SecurityDefaults |
1836 from .Security.SecurityDefaults import SecurityDefaults |
1813 Preferences.getSettings().setValue( |
1837 Preferences.getSettings().setValue( |
1814 "PEP8/HardcodedTmpDirectories", |
1838 "PEP8/HardcodedTmpDirectories", |
1815 SecurityDefaults["hardcoded_tmp_directories"]) |
1839 SecurityDefaults["hardcoded_tmp_directories"]) |
1816 Preferences.getSettings().setValue( |
1840 Preferences.getSettings().setValue( |
1838 "PEP8/WeakKeySizeEcMedium", |
1862 "PEP8/WeakKeySizeEcMedium", |
1839 str(SecurityDefaults["weak_key_size_ec_medium"])) |
1863 str(SecurityDefaults["weak_key_size_ec_medium"])) |
1840 Preferences.getSettings().setValue( |
1864 Preferences.getSettings().setValue( |
1841 "PEP8/CheckTypedException", |
1865 "PEP8/CheckTypedException", |
1842 SecurityDefaults["check_typed_exception"]) |
1866 SecurityDefaults["check_typed_exception"]) |
|
1867 |
|
1868 # Imports Checker |
|
1869 Preferences.getSettings().setValue( |
|
1870 "PEP8/ApplicationModuleNames", []) |
1843 |
1871 |
1844 # Update UI with default values |
1872 # Update UI with default values |
1845 self.on_loadDefaultButton_clicked() |
1873 self.on_loadDefaultButton_clicked() |
1846 |
1874 |
1847 @pyqtSlot() |
1875 @pyqtSlot() |