import re
from fileanalyzer import FileAnalyzer


class PythonAnalyzer(FileAnalyzer):
    def get_class_count(self, content):
        return len(
            re.findall("[^\"](class +[a-zA-Z0-9_]+ *\(?[a-zA-Z0-9_, ]*\)? *:)+[^\"]",
                       content))

    def get_function_count(self, content):
        return len(
            re.findall("[^\"](def +[a-zA-Z0-9_]+ *\([a-zA-Z0-9_, ]*\) *:)+[^\"]", content))

import re
from fileanalyzer import FileAnalyzer


class PythonAnalyzer(FileAnalyzer):
    def get_class_count(self, content):
        matches = re.findall("\"*class +[a-zA-Z0-9_]+ *\(?[a-zA-Z0-9_, ]*\)? *:\"*", content)
        matches = [m for m in matches if m.strip()[0] != "\"" and m.strip()[-1] != "\""]
        return len(matches)

    def get_function_count(self, content):
        matches = re.findall("\"*def +[a-zA-Z0-9_]+ *\([a-zA-Z0-9_, ]*\) *:\"*", content)
        matches = [m for m in matches if m.strip()[0] != "\"" and m.strip()[-1] != "\""]
        return len(matches)

Fix counter to ignore quoted lines
Fix counter to ignore quoted lines

  import re
  from fileanalyzer import FileAnalyzer
  
  
  class PythonAnalyzer(FileAnalyzer):
      def get_class_count(self, content):
+         matches = re.findall("\"*class +[a-zA-Z0-9_]+ *\(?[a-zA-Z0-9_, ]*\)? *:\"*", content)
+         matches = [m for m in matches if m.strip()[0] != "\"" and m.strip()[-1] != "\""]
-         return len(
+         return len(matches)
-             re.findall("[^\"](class +[a-zA-Z0-9_]+ *\(?[a-zA-Z0-9_, ]*\)? *:)+[^\"]",
-                        content))
  
      def get_function_count(self, content):
-         return len(
-             re.findall("[^\"](def +[a-zA-Z0-9_]+ *\([a-zA-Z0-9_, ]*\) *:)+[^\"]", content))
+         matches = re.findall("\"*def +[a-zA-Z0-9_]+ *\([a-zA-Z0-9_, ]*\) *:\"*", content)
+         matches = [m for m in matches if m.strip()[0] != "\"" and m.strip()[-1] != "\""]
+         return len(matches)
  
Fix counter to ignore quoted lines
## Code Before:
import re
from fileanalyzer import FileAnalyzer


class PythonAnalyzer(FileAnalyzer):
    def get_class_count(self, content):
        return len(
            re.findall("[^\"](class +[a-zA-Z0-9_]+ *\(?[a-zA-Z0-9_, ]*\)? *:)+[^\"]",
                       content))

    def get_function_count(self, content):
        return len(
            re.findall("[^\"](def +[a-zA-Z0-9_]+ *\([a-zA-Z0-9_, ]*\) *:)+[^\"]", content))

## Instruction:
Fix counter to ignore quoted lines
## Code After:
import re
from fileanalyzer import FileAnalyzer


class PythonAnalyzer(FileAnalyzer):
    def get_class_count(self, content):
        matches = re.findall("\"*class +[a-zA-Z0-9_]+ *\(?[a-zA-Z0-9_, ]*\)? *:\"*", content)
        matches = [m for m in matches if m.strip()[0] != "\"" and m.strip()[-1] != "\""]
        return len(matches)

    def get_function_count(self, content):
        matches = re.findall("\"*def +[a-zA-Z0-9_]+ *\([a-zA-Z0-9_, ]*\) *:\"*", content)
        matches = [m for m in matches if m.strip()[0] != "\"" and m.strip()[-1] != "\""]
        return len(matches)
