import re
from fileanalyzer import FileAnalyzer


class JavaAnalyzer(FileAnalyzer):
    def get_class_count(self, content):
        return len(
            re.findall("[a-zA-Z ]*class +[a-zA-Z0-9_]+ *\n*\{", content))

    # TODO: Accept angle brackets and decline "else if"
    def get_function_count(self, content):
        return len(
            re.findall(
                "[a-zA-Z ]+ +[a-zA-Z0-9_]+ *\n*\([a-zA-Z0-9_,\[\] \n]*\)[a-zA-Z \n]*\{",
                content))

import re
from fileanalyzer import FileAnalyzer


class JavaAnalyzer(FileAnalyzer):
    def get_class_count(self, content):
        return len(
            re.findall("[a-zA-Z ]*class +[a-zA-Z0-9_<>, ]+\n*\{", content))

    def get_function_count(self, content):
        matches = re.findall(
            "[a-zA-Z <>]+ +[a-zA-Z0-9_]+ *\n*\([a-zA-Z0-9_,\[\]<>\?\. \n]*\)[a-zA-Z \n]*\{",
            content)
        matches = [
            m for m in matches
            if "if " not in m.strip() and "if(" not in m.strip()
        ]
        return len(matches)

Fix regex to match generics
Fix regex to match generics

  import re
  from fileanalyzer import FileAnalyzer
  
  
  class JavaAnalyzer(FileAnalyzer):
      def get_class_count(self, content):
          return len(
-             re.findall("[a-zA-Z ]*class +[a-zA-Z0-9_]+ *\n*\{", content))
+             re.findall("[a-zA-Z ]*class +[a-zA-Z0-9_<>, ]+\n*\{", content))
  
-     # TODO: Accept angle brackets and decline "else if"
      def get_function_count(self, content):
-         return len(
-             re.findall(
+         matches = re.findall(
-                 "[a-zA-Z ]+ +[a-zA-Z0-9_]+ *\n*\([a-zA-Z0-9_,\[\] \n]*\)[a-zA-Z \n]*\{",
+             "[a-zA-Z <>]+ +[a-zA-Z0-9_]+ *\n*\([a-zA-Z0-9_,\[\]<>\?\. \n]*\)[a-zA-Z \n]*\{",
-                 content))
+             content)
+         matches = [
+             m for m in matches
+             if "if " not in m.strip() and "if(" not in m.strip()
+         ]
+         return len(matches)
  
Fix regex to match generics
## Code Before:
import re
from fileanalyzer import FileAnalyzer


class JavaAnalyzer(FileAnalyzer):
    def get_class_count(self, content):
        return len(
            re.findall("[a-zA-Z ]*class +[a-zA-Z0-9_]+ *\n*\{", content))

    # TODO: Accept angle brackets and decline "else if"
    def get_function_count(self, content):
        return len(
            re.findall(
                "[a-zA-Z ]+ +[a-zA-Z0-9_]+ *\n*\([a-zA-Z0-9_,\[\] \n]*\)[a-zA-Z \n]*\{",
                content))

## Instruction:
Fix regex to match generics
## Code After:
import re
from fileanalyzer import FileAnalyzer


class JavaAnalyzer(FileAnalyzer):
    def get_class_count(self, content):
        return len(
            re.findall("[a-zA-Z ]*class +[a-zA-Z0-9_<>, ]+\n*\{", content))

    def get_function_count(self, content):
        matches = re.findall(
            "[a-zA-Z <>]+ +[a-zA-Z0-9_]+ *\n*\([a-zA-Z0-9_,\[\]<>\?\. \n]*\)[a-zA-Z \n]*\{",
            content)
        matches = [
            m for m in matches
            if "if " not in m.strip() and "if(" not in m.strip()
        ]
        return len(matches)
