XMLWordPrintable

      There are a number of number of refactoring opportunities in CpsDataPersistenceService and FragmentRepository classes in cps-ri module:

      • Done in CPS-1664: org.onap.cps.spi.repository.FragmentRepository:55 and 73
        There is unused code in FragmentRepository e.g. findAllByAnchorAndXpathIn. Remove it and any other unused code.
      • Done in CPS-1664: org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java:335
        Method processAncestorXpath is being called twice in queryDataNodes. There is also inappropriate use of ternary operator - an if-else statement would be better! Please clean up this code.{}
      • org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java:441, 442, 85
        I think regex pattern "[\s\S]" means "space character or non-space character" which really means "any character". So "[\s\S]" could be replaced by "." in the regex (verify tests still pass after this change).
      • org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java:495
        There are two methods for updating datanodes - but only second method seems to be used, so it may be safe to delete first method at line 495 - please verify:
        • updateDataNodeAndDescendants(String dataspaceName, String anchorName, DataNode dataNode); // may be safe to remove
        • updateDataNodesAndDescendants(String dataspaceName, String anchorName, Collection<DataNode> updatedDataNodes);
      • Done in CPS-1664: org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java:375
        It has code like:
        ancestorXpaths.isEmpty() ? Collections.emptyList() : fragmentRepository.findAllByXpathIn(ancestorXpaths)

      I don't think this isEmpty() check is needed. JPA repository methods like findAllByXpathIn() are guaranteed to return empty collections on empty inputs.

            raviteja.karumuri Raviteja Karumuri
            danielhanrahan Daniel Hanrahan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: