doorstop icon indicating copy to clipboard operation
doorstop copied to clipboard

Strict child check might be broken

Open togaen opened this issue 5 years ago • 5 comments

If I check our test repo and try the strict child check, I get the below:

$ doorstop --strict-child-check
building tree...
loading documents...
validating items...
Traceback (most recent call last):
  File "~/.local/bin/doorstop", line 8, in <module>
    sys.exit(main())
  File "~/.local/lib/python3.8/site-packages/doorstop/cli/main.py", line 176, in main
    success = function(args, os.getcwd(), parser.error)
  File "~/.local/lib/python3.8/site-packages/doorstop/cli/commands.py", line 98, in run
    valid = tree.validate(skip=args.skip, item_hook=cycle_tracker)
  File "~/.local/lib/python3.8/site-packages/doorstop/core/base.py", line 138, in validate
    for issue in self.get_issues(
  File "~/.local/lib/python3.8/site-packages/doorstop/core/tree.py", line 481, in get_issues
    for issue in chain(
  File "~/.local/lib/python3.8/site-packages/doorstop/core/document.py", line 786, in get_issues
    for issue in chain(
  File "~/.local/lib/python3.8/site-packages/doorstop/core/validators/item_validator.py", line 96, in get_issues
    yield from self._get_issues_both(item, item.document, item.tree, skip)
  File "~/.local/lib/python3.8/site-packages/doorstop/core/validators/item_validator.py", line 214, in _get_issues_both
    prefix = [item.prefix for item in items]
  File "~/.local/lib/python3.8/site-packages/doorstop/core/validators/item_validator.py", line 214, in <listcomp>
    prefix = [item.prefix for item in items]
AttributeError: 'Item' object has no attribute 'prefix'

Looking at line 214 of item_validator.py, if change it from:

prefix = [item.prefix for item in items]

to:

prefix = [item.document.prefix for item in items]

It seems to work as expected. Does this seem right? I'm happy to submit a pull request if it is.

togaen avatar Oct 06 '20 14:10 togaen

Yeah, that sounds like the right fix to me. Feel free to submit a PR!

It looks like the elif settings.CHECK_CHILD_LINKS_STRICT: has zero test coverage so if you could add one to doorstop/core/tests/test_item_validator.py that would be great!

jacebrowning avatar Oct 06 '20 15:10 jacebrowning

Cool, sounds good, I'll submit something later today.

togaen avatar Oct 06 '20 15:10 togaen

@jacebrowning I submitted #491 for the child check. I'll need to familiarize myself a bit more with how doorstop is doing unit testing before I can add one; seems like it should be straightforward, though.

togaen avatar Oct 06 '20 21:10 togaen

@togaen Sounds good! Let me know if you want to merge #491 now or add a test in another PR.

jacebrowning avatar Oct 06 '20 21:10 jacebrowning

@jacebrowning Cool, yeah it's totally fine by me to merge #491 in now. I'll try adding a test in a separate PR.

togaen avatar Oct 06 '20 23:10 togaen

Fixed by #491 and verified by #510.

neerdoc avatar Jan 26 '24 11:01 neerdoc