UNPKG

mcp-server-semgrep

Version:

MCP Server for Semgrep Integration - static code analysis with AI

95 lines (94 loc) 2.6 kB
rules: - id: manual-defaultdict-dict-create message: manually creating a defaultdict - use collections.defaultdict(dict) languages: [python] severity: WARNING pattern-either: - pattern: | $DICT = {} ... for $KEY, $VALUE in $OTHERDICT.items(): ... if $KEY not in $DICT: ... $DICT[$KEY] = {} ... $DICT[$KEY].update(...) - pattern: | $DICT = {} ... for $KEY, $VALUE in $OTHERDICT.items(): ... $DICT.setdefault($KEY, {}).update(...) metadata: category: best-practice technology: - python - id: manual-defaultdict-set-create message: manually creating a defaultdict - use collections.defaultdict(set) languages: [python] severity: WARNING pattern-either: - pattern: | $DICT = {} ... for $KEY, $VALUE in $OTHERDICT.items(): ... if $KEY not in $DICT: ... $DICT[$KEY] = set() ... $DICT[$KEY].add(...) - pattern: | $DICT = {} ... for $KEY, $VALUE in $OTHERDICT.items(): ... $DICT.setdefault($KEY, set()).add(...) metadata: category: best-practice technology: - python - id: manual-defaultdict-list-create message: manually creating a defaultdict - use collections.defaultdict(list) languages: [python] severity: WARNING pattern-either: - pattern: | $DICT = {} ... for $KEY, $VALUE in $OTHERDICT.items(): ... if $KEY not in $DICT: ... $DICT[$KEY] = [] ... $DICT[$KEY].append(...) - pattern: | $DICT = {} ... for $KEY, $VALUE in $OTHERDICT.items(): ... $DICT.setdefault($KEY, []).append(...) metadata: category: best-practice technology: - python - id: manual-counter-create pattern: | $DICT = {} ... for $KEY, $VALUE in $OTHERDICT.items(): ... if $KEY not in $DICT: ... $DICT[$KEY] = 0 ... $DICT[$KEY] += 1 message: manually creating a counter - use collections.Counter languages: [python] severity: WARNING metadata: category: best-practice technology: - python