oracle / opengrok

OpenGrok is a fast and usable source code search and cross reference engine, written in Java
http://oracle.github.io/opengrok/
Other
4.34k stars 745 forks source link

python tools - variable not initialized #2823

Closed tulinkry closed 5 years ago

tulinkry commented 5 years ago
Command output in project 'xxxxxxx' contains errors:
  sudo -u tulinkry opengrok-mirror -c /Users/tulinkry/workspace/tulinkry/OpenGrok/local/mirror-config.yml -U http://localhost:8080 r3
    Traceback (most recent call last):
      File "/usr/local/bin/opengrok-mirror", line 10, in <module>
        sys.exit(main())
      File "/usr/local/lib/python3.7/site-packages/opengrok_tools/mirror.py", line 169, in main
        worker_args.append([x, logdir, args.loglevel,
    UnboundLocalError: local variable 'logdir' referenced before assignment
vladak commented 5 years ago

I see the same warning in IDEA.

vladak commented 5 years ago

Technically, this is not a problem since the worker() will only use logdir if batch is true and __main__() has this:

    # Log messages to dedicated log file if running in batch mode.
    if args.batch:
        logdir = config.get(LOGDIR_PROPERTY)
        if not logdir:
            fatal("The {} property is required in batch mode".
                  format(LOGDIR_PROPERTY))

It should be sufficient to initialize logdir to None.