Code Monkey home page Code Monkey logo

scex's Introduction

scex

Continuous Integration

Extensible, fast and secure Scala expression evaluation engine

Created, developed and maintained at AVSystem.

Quickstart

See Quickstart Example

scex's People

Contributors

ghik avatar ddworak avatar sebaciv avatar bgrochal avatar halotukozak avatar mkrolavs avatar pozar87 avatar mjjaniec avatar

Stargazers

Taketoday avatar  avatar ebigram avatar  avatar  avatar Mike Potanin avatar  avatar Haemin Yoo avatar Rory avatar Anuj Patel avatar  avatar  avatar Andriy Plokhotnyuk avatar Ludovic Claude avatar He-Pin(kerr) avatar Angel Ortega (he/they) avatar Sunghyouk Bae avatar Piyush Purang avatar SwhGo_oN avatar  avatar Mateusz Starzec avatar

Watchers

Krzysztof Kuźnik avatar James Cloos avatar  avatar  avatar  avatar  avatar Dymitr Malczik avatar Szymon Seget avatar  avatar  avatar Michał Wolny avatar  avatar Grzegorz Szeremeta avatar  avatar Daniel Kłódka avatar Miron avatar  avatar Jakub Pinowski avatar  avatar Michał Grabowski avatar Mieszko Mieruński avatar  avatar

scex's Issues

Completer.getErrors gives quite a lot of false positives

Example code:

object ScexFlakyValidation {
 private class DefaultJavaScexCompiler(val settings: ScexSettings)
   extends ScexCompiler
     with ScexPresentationCompiler
     with ClassfileReusingScexCompiler
     with TemplateOptimizingScexCompiler
     with CachingScexCompiler // removing this fixes it, but requires a lower count of tests to not crash (1000 is too much)
     with CachingScexPresentationCompiler
     with WeakReferenceWrappingScexCompiler
     with JavaScexCompiler

 def main(args: Array[String]): Unit = {
   val symbolValidator = SymbolValidator(PredefinedAccessSpecs.basicOperations)
   val symbolAttributes = SymbolAttributes(Nil)
   val syntaxValidator = SyntaxValidator.SimpleExpressions
   val utils = NamedSource("test", "")
   val profile = new ExpressionProfile("test", syntaxValidator, symbolValidator, symbolAttributes, "", utils)
   val settings = new ScexSettings
//    settings.noGetterAdapters.value = true //adding this option fixes it too
   val scexCompiler = new DefaultJavaScexCompiler(settings)
   val completer = scexCompiler.getCompleter[SimpleContext[Any], String](profile, template = false)

   def validateExpr(expr: String): Boolean = completer.getErrors(expr).isEmpty

   val invalidExpression = "symbolMissing" //basically any invalid expression works

   val totalCount = 1000
   val fpCount = (0 until totalCount)
     .map(i => invalidExpression + " " * i) //spaces added to avoid hitting the cache
     .count(validateExpr) // <- this is what gives false positives sometimes (completer.getErrors)

   if (fpCount != 0) {
     println(s"There were $fpCount/$totalCount false positives in validation")
   } else {
     println("all good")
   }
 }
}

This code tries to check for errors on the same invalid expression 1000 times (with added spaces to avoid hitting the cache). The number and order of FPs is nondeterministic, and seems to get higher the longer the code runs, e.g. for 1k times it's around 50-70%:

There were 695/1000 false positives in validation

But for 100 times it's between 10-30%:

There were 12/100 false positives in validation

It seems to not happen with either setting the noGetterAdapters = true in ScexSettings, or when using a ScexCompiler without CachingScexCompiler mixed in, even though those seem to be completely unrelated.

Some other findings:

  • it seems it doesn't matter in what way the expression is invalid, unclosed strings, invalid syntax, missing symbols seem to get false positives at the same rate
  • on the same note, random strings can also be used to check the validation (or something like s"missingSymbol$i")
  • while the false positives are nondeterministic between runs, on the same code run, the same expression always gets the same result (might be some caching tho)
  • The specific caches that seem to affect this problem are profileCompilationResultsCache and javaGetterAdaptersCache. With either of them being removed, and the rest of caches still in place, there are no more FPs
  • ScexPresentationCompiler#Completer.workaroundAssertionError looks like the culprit, but it doesn't affect this at all

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.