<commit_before>package com.sksamuel.scapegoat.inspections

import com.sksamuel.scapegoat.{Inspection, InspectionContext, Inspector, Levels}

/** @author <NAME> */
class EmptyCaseClass extends Inspection {

  def inspector(context: InspectionContext): Inspector = new Inspector(context) {
    override def postTyperTraverser = Some apply  new context.Traverser {

      import context.global._

      def accessors(trees: List[Tree]): List[ValDef] = {
        trees.collect {
          case v: ValDef => v
        }.filter(_.mods.isCaseAccessor)
      }

      override def inspect(tree: Tree): Unit = {
        tree match {
          // body should have constructor only, and with synthetic methods it has 10 in total
          case ClassDef(mods, _, List(), Template(_, _, body)) if mods.isCase && accessors(body).size == 0 =>
            context.warn("Empty case class", tree.pos, Levels.Info,
              "Empty case class can be rewritten as a case object",
              EmptyCaseClass.this)
          case _ => continue(tree)
        }
      }
    }
  }
}
<commit_msg>Use isEmpty instead of comparing to List.size<commit_after>package com.sksamuel.scapegoat.inspections

import com.sksamuel.scapegoat.{Inspection, InspectionContext, Inspector, Levels}

/** @author <NAME> */
class EmptyCaseClass extends Inspection {

  def inspector(context: InspectionContext): Inspector = new Inspector(context) {
    override def postTyperTraverser = Some apply  new context.Traverser {

      import context.global._

      def accessors(trees: List[Tree]): List[ValDef] = {
        trees.collect {
          case v: ValDef => v
        }.filter(_.mods.isCaseAccessor)
      }

      override def inspect(tree: Tree): Unit = {
        tree match {
          // body should have constructor only, and with synthetic methods it has 10 in total
          case ClassDef(mods, _, List(), Template(_, _, body)) if mods.isCase && accessors(body).isEmpty =>
            context.warn("Empty case class", tree.pos, Levels.Info,
              "Empty case class can be rewritten as a case object",
              EmptyCaseClass.this)
          case _ => continue(tree)
        }
      }
    }
  }
}

{'fraction_non_alphanumeric': 0.10219981668194317, 'fraction_numerical': 0.00229147571035747, 'mean_word_length': 2.62624584717608, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '983312', 'n_tokens_mistral': 643, 'n_tokens_neox': 603, 'n_words': 177}