first-row-partial-replacer

Try in Playground
pm-python-ruleset

picimako

UnknownInformational

0

No tags

No CWE or CVE

Pattern Rule: def ${function}(${arg}):


first-row-partial-replacer

How to write a rule
function visit(pattern, filename, code) {
  const funct = pattern.variables.get("function");
  const error = buildError(funct.start.line, funct.start.col, funct.end.line + 1, 8, "Pattern based function highlighting", "CRITICAL", "security");
  const edit = buildEdit(funct.start.line, funct.start.col, funct.end.line + 1, 8, "update", "Replacement text");
  const fix = buildFix("Replace function", [edit]);
  addError(error.addFix(fix));
}

pythonfile.py

Expected test result: no error

Python file

class Person:

  def my_function(self, name):
    p2 = ""

  def __init__(self, name, age, address):
    self.name = name
    self.age = age
    self.address = address

def my_function(name):
  p2 = ""

p1 = Person("Johnd", 36)

my_function(p1.name)

my_function(p1.age)
Add comment

Log in to add a comment


    Be the first one to leave a comment!

Codiga Logo
Codiga Hub
  • Rulesets
  • Explore
  • Cookbooks
  • Playground
soc-2 icon

We are SOC-2 Compliance Certified

G2 high performer medal

Codiga – All rights reserved 2022.