<commit_before>"""pylint plugin to do static analysis on stbt scripts

* Identifies broken image links in parameters to `stbt.wait_for_match` etc.

Intended to be used by "stbt lint".

Documentation on Abstract Syntax Tree traversal with python/pylint:

* http://www.logilab.org/card/pylint_manual#writing-your-own-checker
* http://hg.logilab.org/review/pylint/file/default/examples/custom.py
* http://docs.python.org/2/library/ast.html

"""

import os
import re

# Install `pylint` to get `logilab.astng` modules.
from logilab.astng.node_classes import BinOp, CallFunc, Getattr
from pylint.checkers import BaseChecker

try:  # >= pylint 1.0
    from pylint.interfaces import IAstroidChecker  # pylint: disable=E0611
except ImportError:  # < pylint 1.0
    from pylint.interfaces import IASTNGChecker as IAstroidChecker  # pylint: disable=E0611,C0301


class StbtChecker(BaseChecker):
    __implements__ = IAstroidChecker  # pylint: disable=F0220<commit_msg>stbt lint: [pylint 1.0] work with either logilab.astng or astroid<commit_after>"""pylint plugin to do static analysis on stbt scripts

* Identifies broken image links in parameters to `stbt.wait_for_match` etc.

Intended to be used by "stbt lint".

Documentation on Abstract Syntax Tree traversal with python/pylint:

* http://www.logilab.org/card/pylint_manual#writing-your-own-checker
* http://hg.logilab.org/review/pylint/file/default/examples/custom.py
* http://docs.python.org/2/library/ast.html

"""

import os
import re

# Install `pylint` to get `logilab.astng` or `astroid` modules.
from pylint.checkers import BaseChecker

# pylint: disable=E0611,F0401
try:  # >= pylint 1.0
    from pylint.interfaces import IAstroidChecker
    from astroid.node_classes import BinOp, CallFunc, Getattr
except ImportError:  # < pylint 1.0
    from pylint.interfaces import IASTNGChecker as IAstroidChecker
    from logilab.astng.node_classes import BinOp, CallFunc, Getattr
# pylint: enable=E0611,F0401


class StbtChecker(BaseChecker):
    __implements__ = IAstroidChecker  # pylint: disable=F0220
{'fraction_non_alphanumeric': 0.09414634146341463, 'fraction_numerical': 0.023414634146341463, 'mean_word_length': 4.777464788732394, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4294566', 'n_tokens_mistral': 739, 'n_tokens_neox': 710, 'n_words': 182}