lirantal/is-website-vulnerable

Inject lighthouse initialisation parameters

zivkaziv opened this issue · 6 comments

Is your feature request related to a problem? Please describe.
Every new lighthouse flag/ scan configuration/ whatever will require changes in the Audit class. Instead I think we should build the lighthouse parameters outside the Audit class, and inject it.
I think it will give more flexibility for more complex configurations, and less risk for regression bugs in the future.

Describe the solution you'd like

module.exports = class Audit {
  constructor(lighthouseConfig) {
    this.lighthouseConfig = lighthouseConfig || lighthouse.defaultConfig
    }
  }
  ...

    this.lighthouseConfig.opts.port =  this.lighthouseConfig.opts.port || chromeInstance.port
    debug(`invoking lighthouse scan for: ${url}`)
    const scanResult = await lighthouse(url,   this.lighthouseConfig.opts, this.lighthouseConfig.config);
....

Describe alternatives you've considered
Keep it the way it is:)

I'm not entirely sure how this is a better approach though? you are still passing options to lighthouse's function call as far as I can see in that last line of code:

    const scanResult = await lighthouse(url,   this.lighthouseConfig.opts, this.lighthouseConfig.config);

Just in order not to change Audit class for every change of configuration. Make it more functional

Again, lighthouse configuration can change much more then the audit.scanUrl()..

yeah but why do we need to provide it in the function call lighthouse() if it is already provided to the constructor? I think that kind of refactor can be ok.

Zvika I'll close this for now unless you'd want to pursue it later with some action where we can re-open it

NP..
Thank you:)