<commit_before>// vim: fdm=marker et ts=2 sw=2 tw=80 fo=tcqwn list
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.debiki.v0

import java.{util => ju}

object Prelude {

  /** Converts from a perhaps-{@code null} reference to an {@code Option}.
   */
  def ?[A <: AnyRef](x: A): Option[A] = if (x eq null) None else Some(x)

  import java.lang.{UnsupportedOperationException => UOE}

  def unsupported = throw new UOE
  def unsupported(what: String) = throw new UOE(what)
  def unimplemented = throw new UOE("Not implemented")
  def unimplemented(what: String) = throw new UOE("Not implemented: "+ what)
  def unimplementedIf(condition: Boolean, what: String) =
    if (condition) unimplemented(what)

  /** Write UNTESTED anywhere, not in a comment, and the compiler
   *  ensures you don't do a typo, so you'll find all UNTESTED should
   *  you search for UNTESTED before a release (intending to write unit tests).
   */
  def UNTESTED = ()

  def errorIf(condition: Boolean, problem: String) =
    if (condition) throw new RuntimeException(problem)

  def assertionError(problem: String) =
    throw new AssertionError(problem)<commit_msg>Add XSS, XSRF, TODO, COULD etc. words.<commit_after>// vim: fdm=marker et ts=2 sw=2 tw=80 fo=tcqwn list
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.debiki.v0

import java.{util => ju}

object Prelude {

  /** Converts from a perhaps-{@code null} reference to an {@code Option}.
   */
  def ?[A <: AnyRef](x: A): Option[A] = if (x eq null) None else Some(x)

  import java.lang.{UnsupportedOperationException => UOE}

  def unsupported = throw new UOE
  def unsupported(what: String) = throw new UOE(what)
  def unimplemented = throw new UOE("Not implemented")
  def unimplemented(what: String) = throw new UOE("Not implemented: "+ what)
  def unimplementedIf(condition: Boolean, what: String) =
    if (condition) unimplemented(what)

  /** Write UNTESTED anywhere, not in a comment, and the compiler
   *  ensures you don't do a typo, so you'll find all UNTESTED should
   *  you search for UNTESTED before a release (intending to write unit tests).
   */
  def UNTESTED = ()  // If the code might not work, e.g. has never been run.
  def SECURITY = ()  // General security issue, should be fixed before release.
  def XSRF = ()  // Cross site request forgery.
  def XSS = ()  // Cross site scripting.
  def BUG = ()  // Need not be a terribly important bug.
  def TODO = ()  // Do this, or people might notice and complain.
  def COULD = ()  // Could do this, but it's not that important.

  def errorIf(condition: Boolean, problem: String) =
    if (condition) throw new RuntimeException(problem)

  def assertionError(problem: String) =
    throw new AssertionError(problem)
{'fraction_non_alphanumeric': 0.10823117338003503, 'fraction_numerical': 0.0035026269702276708, 'mean_word_length': 3.61389337641357, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3829945', 'n_tokens_mistral': 924, 'n_tokens_neox': 870, 'n_words': 346}