src/eric7/Documentation/Source/eric7.Plugins.CheckerPlugins.CodeStyleChecker.Miscellaneous.MiscellaneousChecker.html

branch
eric7
changeset 10368
8765229e7cc8
parent 10358
957c9de01d42
child 10417
c6011e501282
equal deleted inserted replaced
10367:b189ca1f5d53 10368:8765229e7cc8
27 <tr> 27 <tr>
28 <td><a href="#DateTimeVisitor">DateTimeVisitor</a></td> 28 <td><a href="#DateTimeVisitor">DateTimeVisitor</a></td>
29 <td>Class implementing a node visitor to check datetime function calls.</td> 29 <td>Class implementing a node visitor to check datetime function calls.</td>
30 </tr> 30 </tr>
31 <tr> 31 <tr>
32 <td><a href="#LoggingVisitor">LoggingVisitor</a></td>
33 <td>Class implementing a node visitor to check logging statements.</td>
34 </tr>
35 <tr>
36 <td><a href="#M520NameFinder">M520NameFinder</a></td> 32 <td><a href="#M520NameFinder">M520NameFinder</a></td>
37 <td>Class to extract a name out of a tree of nodes ignoring names defined within the local scope of a comprehension.</td> 33 <td>Class to extract a name out of a tree of nodes ignoring names defined within the local scope of a comprehension.</td>
38 </tr> 34 </tr>
39 <tr> 35 <tr>
40 <td><a href="#MiscellaneousChecker">MiscellaneousChecker</a></td> 36 <td><a href="#MiscellaneousChecker">MiscellaneousChecker</a></td>
62 <table> 58 <table>
63 59
64 <tr> 60 <tr>
65 <td><a href="#composeCallPath">composeCallPath</a></td> 61 <td><a href="#composeCallPath">composeCallPath</a></td>
66 <td>Generator function to assemble the call path of a given node.</td> 62 <td>Generator function to assemble the call path of a given node.</td>
63 </tr>
64 <tr>
65 <td><a href="#pairwise">pairwise</a></td>
66 <td></td>
67 </tr> 67 </tr>
68 </table> 68 </table>
69 <hr /> 69 <hr />
70 <hr /> 70 <hr />
71 <a NAME="BugBearVisitor" ID="BugBearVisitor"></a> 71 <a NAME="BugBearVisitor" ID="BugBearVisitor"></a>
1507 </dd> 1507 </dd>
1508 </dl> 1508 </dl>
1509 <div align="right"><a href="#top">Up</a></div> 1509 <div align="right"><a href="#top">Up</a></div>
1510 <hr /> 1510 <hr />
1511 <hr /> 1511 <hr />
1512 <a NAME="LoggingVisitor" ID="LoggingVisitor"></a>
1513 <h2>LoggingVisitor</h2>
1514
1515 <p>
1516 Class implementing a node visitor to check logging statements.
1517 </p>
1518 <h3>Derived from</h3>
1519 ast.NodeVisitor
1520 <h3>Class Attributes</h3>
1521
1522 <table>
1523 <tr><td>LoggingLevels</td></tr>
1524 </table>
1525 <h3>Class Methods</h3>
1526
1527 <table>
1528 <tr><td>None</td></tr>
1529 </table>
1530 <h3>Methods</h3>
1531
1532 <table>
1533
1534 <tr>
1535 <td><a href="#LoggingVisitor.__init__">LoggingVisitor</a></td>
1536 <td>Constructor</td>
1537 </tr>
1538 <tr>
1539 <td><a href="#LoggingVisitor.__detectLoggingLevel">__detectLoggingLevel</a></td>
1540 <td>Private method to decide whether an AST Call is a logging call.</td>
1541 </tr>
1542 <tr>
1543 <td><a href="#LoggingVisitor.__isFormatCall">__isFormatCall</a></td>
1544 <td>Private method to check if a function call uses format.</td>
1545 </tr>
1546 <tr>
1547 <td><a href="#LoggingVisitor.__withinExtraKeyword">__withinExtraKeyword</a></td>
1548 <td>Private method to check, if we are inside the extra keyword.</td>
1549 </tr>
1550 <tr>
1551 <td><a href="#LoggingVisitor.__withinLoggingArgument">__withinLoggingArgument</a></td>
1552 <td>Private method to check, if we are inside a logging argument.</td>
1553 </tr>
1554 <tr>
1555 <td><a href="#LoggingVisitor.__withinLoggingStatement">__withinLoggingStatement</a></td>
1556 <td>Private method to check, if we are inside a logging statement.</td>
1557 </tr>
1558 <tr>
1559 <td><a href="#LoggingVisitor.visit_BinOp">visit_BinOp</a></td>
1560 <td>Public method to handle binary operations while processing the first logging argument.</td>
1561 </tr>
1562 <tr>
1563 <td><a href="#LoggingVisitor.visit_Call">visit_Call</a></td>
1564 <td>Public method to handle a function call.</td>
1565 </tr>
1566 <tr>
1567 <td><a href="#LoggingVisitor.visit_JoinedStr">visit_JoinedStr</a></td>
1568 <td>Public method to handle f-string arguments.</td>
1569 </tr>
1570 </table>
1571 <h3>Static Methods</h3>
1572
1573 <table>
1574 <tr><td>None</td></tr>
1575 </table>
1576
1577 <a NAME="LoggingVisitor.__init__" ID="LoggingVisitor.__init__"></a>
1578 <h4>LoggingVisitor (Constructor)</h4>
1579 <b>LoggingVisitor</b>(<i></i>)
1580
1581 <p>
1582 Constructor
1583 </p>
1584 <a NAME="LoggingVisitor.__detectLoggingLevel" ID="LoggingVisitor.__detectLoggingLevel"></a>
1585 <h4>LoggingVisitor.__detectLoggingLevel</h4>
1586 <b>__detectLoggingLevel</b>(<i>node</i>)
1587
1588 <p>
1589 Private method to decide whether an AST Call is a logging call.
1590 </p>
1591 <dl>
1592
1593 <dt><i>node</i> (ast.Call)</dt>
1594 <dd>
1595 reference to the node to be processed
1596 </dd>
1597 </dl>
1598 <dl>
1599 <dt>Return:</dt>
1600 <dd>
1601 logging level
1602 </dd>
1603 </dl>
1604 <dl>
1605 <dt>Return Type:</dt>
1606 <dd>
1607 str or None
1608 </dd>
1609 </dl>
1610 <a NAME="LoggingVisitor.__isFormatCall" ID="LoggingVisitor.__isFormatCall"></a>
1611 <h4>LoggingVisitor.__isFormatCall</h4>
1612 <b>__isFormatCall</b>(<i>node</i>)
1613
1614 <p>
1615 Private method to check if a function call uses format.
1616 </p>
1617 <dl>
1618
1619 <dt><i>node</i> (ast.Call)</dt>
1620 <dd>
1621 reference to the node to be processed
1622 </dd>
1623 </dl>
1624 <dl>
1625 <dt>Return:</dt>
1626 <dd>
1627 flag indicating the function call uses format
1628 </dd>
1629 </dl>
1630 <dl>
1631 <dt>Return Type:</dt>
1632 <dd>
1633 bool
1634 </dd>
1635 </dl>
1636 <a NAME="LoggingVisitor.__withinExtraKeyword" ID="LoggingVisitor.__withinExtraKeyword"></a>
1637 <h4>LoggingVisitor.__withinExtraKeyword</h4>
1638 <b>__withinExtraKeyword</b>(<i>node</i>)
1639
1640 <p>
1641 Private method to check, if we are inside the extra keyword.
1642 </p>
1643 <dl>
1644
1645 <dt><i>node</i> (ast.keyword)</dt>
1646 <dd>
1647 reference to the node to be checked
1648 </dd>
1649 </dl>
1650 <dl>
1651 <dt>Return:</dt>
1652 <dd>
1653 flag indicating we are inside the extra keyword
1654 </dd>
1655 </dl>
1656 <dl>
1657 <dt>Return Type:</dt>
1658 <dd>
1659 bool
1660 </dd>
1661 </dl>
1662 <a NAME="LoggingVisitor.__withinLoggingArgument" ID="LoggingVisitor.__withinLoggingArgument"></a>
1663 <h4>LoggingVisitor.__withinLoggingArgument</h4>
1664 <b>__withinLoggingArgument</b>(<i></i>)
1665
1666 <p>
1667 Private method to check, if we are inside a logging argument.
1668 </p>
1669 <dl>
1670 <dt>Return:</dt>
1671 <dd>
1672 flag indicating we are inside a logging argument
1673 </dd>
1674 </dl>
1675 <dl>
1676 <dt>Return Type:</dt>
1677 <dd>
1678 bool
1679 </dd>
1680 </dl>
1681 <a NAME="LoggingVisitor.__withinLoggingStatement" ID="LoggingVisitor.__withinLoggingStatement"></a>
1682 <h4>LoggingVisitor.__withinLoggingStatement</h4>
1683 <b>__withinLoggingStatement</b>(<i></i>)
1684
1685 <p>
1686 Private method to check, if we are inside a logging statement.
1687 </p>
1688 <dl>
1689 <dt>Return:</dt>
1690 <dd>
1691 flag indicating we are inside a logging statement
1692 </dd>
1693 </dl>
1694 <dl>
1695 <dt>Return Type:</dt>
1696 <dd>
1697 bool
1698 </dd>
1699 </dl>
1700 <a NAME="LoggingVisitor.visit_BinOp" ID="LoggingVisitor.visit_BinOp"></a>
1701 <h4>LoggingVisitor.visit_BinOp</h4>
1702 <b>visit_BinOp</b>(<i>node</i>)
1703
1704 <p>
1705 Public method to handle binary operations while processing the first
1706 logging argument.
1707 </p>
1708 <dl>
1709
1710 <dt><i>node</i> (ast.BinOp)</dt>
1711 <dd>
1712 reference to the node to be processed
1713 </dd>
1714 </dl>
1715 <a NAME="LoggingVisitor.visit_Call" ID="LoggingVisitor.visit_Call"></a>
1716 <h4>LoggingVisitor.visit_Call</h4>
1717 <b>visit_Call</b>(<i>node</i>)
1718
1719 <p>
1720 Public method to handle a function call.
1721 </p>
1722 <p>
1723 Every logging statement and string format is expected to be a function
1724 call.
1725 </p>
1726 <dl>
1727
1728 <dt><i>node</i> (ast.Call)</dt>
1729 <dd>
1730 reference to the node to be processed
1731 </dd>
1732 </dl>
1733 <a NAME="LoggingVisitor.visit_JoinedStr" ID="LoggingVisitor.visit_JoinedStr"></a>
1734 <h4>LoggingVisitor.visit_JoinedStr</h4>
1735 <b>visit_JoinedStr</b>(<i>node</i>)
1736
1737 <p>
1738 Public method to handle f-string arguments.
1739 </p>
1740 <dl>
1741
1742 <dt><i>node</i> (ast.JoinedStr)</dt>
1743 <dd>
1744 reference to the node to be processed
1745 </dd>
1746 </dl>
1747 <div align="right"><a href="#top">Up</a></div>
1748 <hr />
1749 <hr />
1750 <a NAME="M520NameFinder" ID="M520NameFinder"></a> 1512 <a NAME="M520NameFinder" ID="M520NameFinder"></a>
1751 <h2>M520NameFinder</h2> 1513 <h2>M520NameFinder</h2>
1752 1514
1753 <p> 1515 <p>
1754 Class to extract a name out of a tree of nodes ignoring names defined within the 1516 Class to extract a name out of a tree of nodes ignoring names defined within the
1927 <tr> 1689 <tr>
1928 <td><a href="#MiscellaneousChecker.__checkDictWithSortedKeys">__checkDictWithSortedKeys</a></td> 1690 <td><a href="#MiscellaneousChecker.__checkDictWithSortedKeys">__checkDictWithSortedKeys</a></td>
1929 <td>Private method to check, if dictionary keys appear in sorted order.</td> 1691 <td>Private method to check, if dictionary keys appear in sorted order.</td>
1930 </tr> 1692 </tr>
1931 <tr> 1693 <tr>
1694 <td><a href="#MiscellaneousChecker.__checkExplicitStringConcat">__checkExplicitStringConcat</a></td>
1695 <td>Private method to check for explicitly concatenated strings.</td>
1696 </tr>
1697 <tr>
1932 <td><a href="#MiscellaneousChecker.__checkFormatString">__checkFormatString</a></td> 1698 <td><a href="#MiscellaneousChecker.__checkFormatString">__checkFormatString</a></td>
1933 <td>Private method to check string format strings.</td> 1699 <td>Private method to check string format strings.</td>
1934 </tr> 1700 </tr>
1935 <tr> 1701 <tr>
1936 <td><a href="#MiscellaneousChecker.__checkFuture">__checkFuture</a></td> 1702 <td><a href="#MiscellaneousChecker.__checkFuture">__checkFuture</a></td>
1939 <tr> 1705 <tr>
1940 <td><a href="#MiscellaneousChecker.__checkGettext">__checkGettext</a></td> 1706 <td><a href="#MiscellaneousChecker.__checkGettext">__checkGettext</a></td>
1941 <td>Private method to check the 'gettext' import statement.</td> 1707 <td>Private method to check the 'gettext' import statement.</td>
1942 </tr> 1708 </tr>
1943 <tr> 1709 <tr>
1710 <td><a href="#MiscellaneousChecker.__checkImplicitStringConcat">__checkImplicitStringConcat</a></td>
1711 <td>Private method to check for implicitly concatenated strings.</td>
1712 </tr>
1713 <tr>
1944 <td><a href="#MiscellaneousChecker.__checkLineContinuation">__checkLineContinuation</a></td> 1714 <td><a href="#MiscellaneousChecker.__checkLineContinuation">__checkLineContinuation</a></td>
1945 <td>Private method to check line continuation using backslash.</td> 1715 <td>Private method to check line continuation using backslash.</td>
1946 </tr> 1716 </tr>
1947 <tr> 1717 <tr>
1948 <td><a href="#MiscellaneousChecker.__checkLogging">__checkLogging</a></td>
1949 <td>Private method to check logging statements.</td>
1950 </tr>
1951 <tr>
1952 <td><a href="#MiscellaneousChecker.__checkMutableDefault">__checkMutableDefault</a></td> 1718 <td><a href="#MiscellaneousChecker.__checkMutableDefault">__checkMutableDefault</a></td>
1953 <td>Private method to check for use of mutable types as default arguments.</td> 1719 <td>Private method to check for use of mutable types as default arguments.</td>
1954 </tr> 1720 </tr>
1955 <tr> 1721 <tr>
1956 <td><a href="#MiscellaneousChecker.__checkPep3101">__checkPep3101</a></td> 1722 <td><a href="#MiscellaneousChecker.__checkPep3101">__checkPep3101</a></td>
1993 <td>Private method to extract the format field information.</td> 1759 <td>Private method to extract the format field information.</td>
1994 </tr> 1760 </tr>
1995 <tr> 1761 <tr>
1996 <td><a href="#MiscellaneousChecker.__ignoreCode">__ignoreCode</a></td> 1762 <td><a href="#MiscellaneousChecker.__ignoreCode">__ignoreCode</a></td>
1997 <td>Private method to check if the message code should be ignored.</td> 1763 <td>Private method to check if the message code should be ignored.</td>
1764 </tr>
1765 <tr>
1766 <td><a href="#MiscellaneousChecker.__isImplicitStringConcat">__isImplicitStringConcat</a></td>
1767 <td>Private method to check, if the given strings indicate an implicit string concatenation.</td>
1998 </tr> 1768 </tr>
1999 <tr> 1769 <tr>
2000 <td><a href="#MiscellaneousChecker.run">run</a></td> 1770 <td><a href="#MiscellaneousChecker.run">run</a></td>
2001 <td>Public method to check the given source against miscellaneous conditions.</td> 1771 <td>Public method to check the given source against miscellaneous conditions.</td>
2002 </tr> 1772 </tr>
2083 <b>__checkComprehensions</b>(<i></i>) 1853 <b>__checkComprehensions</b>(<i></i>)
2084 1854
2085 <p> 1855 <p>
2086 Private method to check some comprehension related things. 1856 Private method to check some comprehension related things.
2087 </p> 1857 </p>
1858 <p>
1859 This method is adapted from: flake8-comprehensions v3.14.0
1860 Original: Copyright (c) 2017 Adam Johnson
1861 </p>
2088 <a NAME="MiscellaneousChecker.__checkCopyright" ID="MiscellaneousChecker.__checkCopyright"></a> 1862 <a NAME="MiscellaneousChecker.__checkCopyright" ID="MiscellaneousChecker.__checkCopyright"></a>
2089 <h4>MiscellaneousChecker.__checkCopyright</h4> 1863 <h4>MiscellaneousChecker.__checkCopyright</h4>
2090 <b>__checkCopyright</b>(<i></i>) 1864 <b>__checkCopyright</b>(<i></i>)
2091 1865
2092 <p> 1866 <p>
2104 <b>__checkDictWithSortedKeys</b>(<i></i>) 1878 <b>__checkDictWithSortedKeys</b>(<i></i>)
2105 1879
2106 <p> 1880 <p>
2107 Private method to check, if dictionary keys appear in sorted order. 1881 Private method to check, if dictionary keys appear in sorted order.
2108 </p> 1882 </p>
1883 <a NAME="MiscellaneousChecker.__checkExplicitStringConcat" ID="MiscellaneousChecker.__checkExplicitStringConcat"></a>
1884 <h4>MiscellaneousChecker.__checkExplicitStringConcat</h4>
1885 <b>__checkExplicitStringConcat</b>(<i></i>)
1886
1887 <p>
1888 Private method to check for explicitly concatenated strings.
1889 </p>
2109 <a NAME="MiscellaneousChecker.__checkFormatString" ID="MiscellaneousChecker.__checkFormatString"></a> 1890 <a NAME="MiscellaneousChecker.__checkFormatString" ID="MiscellaneousChecker.__checkFormatString"></a>
2110 <h4>MiscellaneousChecker.__checkFormatString</h4> 1891 <h4>MiscellaneousChecker.__checkFormatString</h4>
2111 <b>__checkFormatString</b>(<i></i>) 1892 <b>__checkFormatString</b>(<i></i>)
2112 1893
2113 <p> 1894 <p>
2125 <b>__checkGettext</b>(<i></i>) 1906 <b>__checkGettext</b>(<i></i>)
2126 1907
2127 <p> 1908 <p>
2128 Private method to check the 'gettext' import statement. 1909 Private method to check the 'gettext' import statement.
2129 </p> 1910 </p>
1911 <a NAME="MiscellaneousChecker.__checkImplicitStringConcat" ID="MiscellaneousChecker.__checkImplicitStringConcat"></a>
1912 <h4>MiscellaneousChecker.__checkImplicitStringConcat</h4>
1913 <b>__checkImplicitStringConcat</b>(<i></i>)
1914
1915 <p>
1916 Private method to check for implicitly concatenated strings.
1917 </p>
2130 <a NAME="MiscellaneousChecker.__checkLineContinuation" ID="MiscellaneousChecker.__checkLineContinuation"></a> 1918 <a NAME="MiscellaneousChecker.__checkLineContinuation" ID="MiscellaneousChecker.__checkLineContinuation"></a>
2131 <h4>MiscellaneousChecker.__checkLineContinuation</h4> 1919 <h4>MiscellaneousChecker.__checkLineContinuation</h4>
2132 <b>__checkLineContinuation</b>(<i></i>) 1920 <b>__checkLineContinuation</b>(<i></i>)
2133 1921
2134 <p> 1922 <p>
2135 Private method to check line continuation using backslash. 1923 Private method to check line continuation using backslash.
2136 </p> 1924 </p>
2137 <a NAME="MiscellaneousChecker.__checkLogging" ID="MiscellaneousChecker.__checkLogging"></a>
2138 <h4>MiscellaneousChecker.__checkLogging</h4>
2139 <b>__checkLogging</b>(<i></i>)
2140
2141 <p>
2142 Private method to check logging statements.
2143 </p>
2144 <a NAME="MiscellaneousChecker.__checkMutableDefault" ID="MiscellaneousChecker.__checkMutableDefault"></a> 1925 <a NAME="MiscellaneousChecker.__checkMutableDefault" ID="MiscellaneousChecker.__checkMutableDefault"></a>
2145 <h4>MiscellaneousChecker.__checkMutableDefault</h4> 1926 <h4>MiscellaneousChecker.__checkMutableDefault</h4>
2146 <b>__checkMutableDefault</b>(<i></i>) 1927 <b>__checkMutableDefault</b>(<i></i>)
2147 1928
2148 <p> 1929 <p>
2310 </dl> 2091 </dl>
2311 <dl> 2092 <dl>
2312 <dt>Return Type:</dt> 2093 <dt>Return Type:</dt>
2313 <dd> 2094 <dd>
2314 bool 2095 bool
2096 </dd>
2097 </dl>
2098 <a NAME="MiscellaneousChecker.__isImplicitStringConcat" ID="MiscellaneousChecker.__isImplicitStringConcat"></a>
2099 <h4>MiscellaneousChecker.__isImplicitStringConcat</h4>
2100 <b>__isImplicitStringConcat</b>(<i>first, second</i>)
2101
2102 <p>
2103 Private method to check, if the given strings indicate an implicit string
2104 concatenation.
2105 </p>
2106 <dl>
2107
2108 <dt><i>first</i> (tuple)</dt>
2109 <dd>
2110 first token
2111 </dd>
2112 <dt><i>second</i> (tuple)</dt>
2113 <dd>
2114 second token
2115 </dd>
2116 </dl>
2117 <dl>
2118 <dt>Return:</dt>
2119 <dd>
2120 flag indicating an implicit string concatenation
2315 </dd> 2121 </dd>
2316 </dl> 2122 </dl>
2317 <a NAME="MiscellaneousChecker.run" ID="MiscellaneousChecker.run"></a> 2123 <a NAME="MiscellaneousChecker.run" ID="MiscellaneousChecker.run"></a>
2318 <h4>MiscellaneousChecker.run</h4> 2124 <h4>MiscellaneousChecker.run</h4>
2319 <b>run</b>(<i></i>) 2125 <b>run</b>(<i></i>)
3390 str 3196 str
3391 </dd> 3197 </dd>
3392 </dl> 3198 </dl>
3393 <div align="right"><a href="#top">Up</a></div> 3199 <div align="right"><a href="#top">Up</a></div>
3394 <hr /> 3200 <hr />
3201 <hr />
3202 <a NAME="pairwise" ID="pairwise"></a>
3203 <h2>pairwise</h2>
3204 <b>pairwise</b>(<i>iterable</i>)
3205
3206 <div align="right"><a href="#top">Up</a></div>
3207 <hr />
3395 </body></html> 3208 </body></html>

eric ide

mercurial