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 |
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> |
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> |