<commit_before>package com.vanniktech.lintrules.android

import com.android.tools.lint.client.api.UElementHandler
import com.android.tools.lint.detector.api.Category.Companion.CORRECTNESS
import com.android.tools.lint.detector.api.Detector
import com.android.tools.lint.detector.api.Implementation
import com.android.tools.lint.detector.api.Issue
import com.android.tools.lint.detector.api.JavaContext
import com.android.tools.lint.detector.api.Scope.JAVA_FILE
import com.android.tools.lint.detector.api.Scope.TEST_SOURCES
import com.android.tools.lint.detector.api.Severity.WARNING
import com.intellij.psi.PsiNamedElement
import org.jetbrains.uast.UClass
import org.jetbrains.uast.UElement
import org.jetbrains.uast.UEnumConstant
import org.jetbrains.uast.UMethod
import org.jetbrains.uast.UVariable
import java.util.EnumSet

val ISSUE_NAMING_PATTERN = Issue.create("NamingPattern",
    "Names should be well named.",
    """Sometimes there is more than one reasonable way to convert an English phrase into camel case, such as when acronyms or unusual constructs like "IPv6" or "iOS" are present. XML HTTP request becomes XmlHttpRequest. XMLHTTPRequest would be incorrect.""",
    CORRECTNESS, PRIORITY, WARNING,
    Implementation(NamingPatternDetector::class.java, EnumSet.of(JAVA_FILE, TEST_SOURCES)))

class NamingPatternDetector : Detector(), Detector.UastScanner {
  override fun getApplicableUastTypes() = listOf<Class<out UElement>>(UVariable::class.java, UMethod::class.java, UClass::class.java)

  override fun createUastHandler(context: JavaContext) = NamingPatternHandler(context)

  inner class NamingPatternHandler(private val context: JavaContext) : UElementHandler() {
    override fun visitVariable(node: UVariable) {
      val isConstant = node.isFinal && node.isStatic
      val isEnumConstant = node is UEnumConstant

      if (!isConstant && !isEnumConstant) {
        process(node, node)
      }
    }

    override fun visitMethod(node: UMethod) {
      process(node, node)
    }

    override fun visitClass(node: UClass) {
      process(node, node)
    }
<commit_msg>NamingPatternDetector: No Need for inner keyword in NamingPatternHandler. (#201)<commit_after>package com.vanniktech.lintrules.android

import com.android.tools.lint.client.api.UElementHandler
import com.android.tools.lint.detector.api.Category.Companion.CORRECTNESS
import com.android.tools.lint.detector.api.Detector
import com.android.tools.lint.detector.api.Implementation
import com.android.tools.lint.detector.api.Issue
import com.android.tools.lint.detector.api.JavaContext
import com.android.tools.lint.detector.api.Scope.JAVA_FILE
import com.android.tools.lint.detector.api.Scope.TEST_SOURCES
import com.android.tools.lint.detector.api.Severity.WARNING
import com.intellij.psi.PsiNamedElement
import org.jetbrains.uast.UClass
import org.jetbrains.uast.UElement
import org.jetbrains.uast.UEnumConstant
import org.jetbrains.uast.UMethod
import org.jetbrains.uast.UVariable
import java.util.EnumSet

val ISSUE_NAMING_PATTERN = Issue.create("NamingPattern",
    "Names should be well named.",
    """Sometimes there is more than one reasonable way to convert an English phrase into camel case, such as when acronyms or unusual constructs like "IPv6" or "iOS" are present. XML HTTP request becomes XmlHttpRequest. XMLHTTPRequest would be incorrect.""",
    CORRECTNESS, PRIORITY, WARNING,
    Implementation(NamingPatternDetector::class.java, EnumSet.of(JAVA_FILE, TEST_SOURCES)))

class NamingPatternDetector : Detector(), Detector.UastScanner {
  override fun getApplicableUastTypes() = listOf<Class<out UElement>>(UVariable::class.java, UMethod::class.java, UClass::class.java)

  override fun createUastHandler(context: JavaContext) = NamingPatternHandler(context)

  class NamingPatternHandler(private val context: JavaContext) : UElementHandler() {
    override fun visitVariable(node: UVariable) {
      val isConstant = node.isFinal && node.isStatic
      val isEnumConstant = node is UEnumConstant

      if (!isConstant && !isEnumConstant) {
        process(node, node)
      }
    }

    override fun visitMethod(node: UMethod) {
      process(node, node)
    }

    override fun visitClass(node: UClass) {
      process(node, node)
    }

{'fraction_non_alphanumeric': 0.0958323522486461, 'fraction_numerical': 0.0011773016246762421, 'mean_word_length': 4.974683544303797, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4632467', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1271, 'n_words': 285}