Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing support for multiple analyzers to polystat/odin #44

Open
nikololiahim opened this issue Mar 3, 2022 · 0 comments
Open

Introducing support for multiple analyzers to polystat/odin #44

nikololiahim opened this issue Mar 3, 2022 · 0 comments

Comments

@nikololiahim
Copy link
Member

The current interface of EOOdinAnalyzer.EOOdinXmirAnalyzer() has the following signature:

trait EOOdinAnalyzer[R] {
  @throws[Exception]
  def analyze(
    eoRepr: R
  ): java.util.List[OdinAnalysisErrorInterop]
}

This signature works fine for a single analyzer. It either returns a result (which is a List of errors) or fails with an Exception. Problems begin when we try to cram multiple analyzers into this interface. Let's say we run 2 analyzers: the 1st succeeds and the 2nd fails. In this case we get only an exception coming from the 2nd analyzer, whereas the results of the 1st are lost.

So, if we want to support running multiple analyzers, then the shape of this API has to change. The most straightforward seems to parameterize the interface not only by the input type, but also by the analysis type:

trait EOOdinAnalyzer[R, A] { // A stands for AnalysisType
  @throws[Exception]
  def analyze(
    eoRepr: R,
    analyzer: A
  ): java.util.List[OdinAnalysisErrorInterop]
}

And then implement if for a second analyzer:

class EOOdinXmirAnalyzerThirdDefect() extends EOOdinAnalyzer[String, ThirdDefect] {
    override def analyze(eoRepr: String, analyzer: ThirdDefect): util.List[OdinAnalysisErrorInterop] = {
      // implementation goes here
    }
  }

@yegor256 what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant