Issue 59: DependencyConstraintException should report the violating class

0 views
Skip to first unread message

Mike Nereson

unread,
Aug 16, 2008, 12:22:01 AM8/16/08
to architectur...@googlegroups.com
This issues has been an issue for a while, but just recently got into the issue list http://code.google.com/p/architecturerules/issues/detail?id=59

I was able to modify the code to not only list every class in the package but to look at each class's imports to figure out which class was actually importing the other package in the cycle. By doing this on both ends we can find the exact classes causing the cycle. I actually didn't need to do much. The JDapend JavaClass has a Collection of imported packages at javaClass.getImportedPackages() so I just checked that.

I need to update thet CyclicRedundancyException metadata to reflect this new information.


I changed the output exception message a little bit. I'd like to see this totally revamped. It's pretty hard to read:

org.architecturerules.exceptions.CyclicRedundancyException: 5 cyclic dependencies found:

    -- org.architecturerules.exceptions depends on
    |  |
    |  |-- org.architecturerules.domain
    |     |-- @ IllegalArchitectureRuleExceptionTest.java
    |     |-- @ DependencyConstraintExceptionTest.java
    |     |-- @ NoPackagesFoundExceptionTest.java
    |     |-- @ SourceNotFoundExceptionTest.java
    |        \ while
    |         |-- RuleTest.java
    |           \ depends on org.architecturerules.exceptions
    |
    -- test.com.seventytwomiles.services depends on
    |  |
    |  |-- test.com.seventytwomiles.model
    |     |-- @ PersonService.java
    |     |-- @ PersonServiceImpl.java
    |        \ while
    |         |-- Person.java
    |           \ depends on test.com.seventytwomiles.services
    |  |-- test.com.seventytwomiles.dao.hibernate
    |     |-- @ PersonServiceImpl.java
    |        \ while
    |         |-- PersonDaoImpl.java
    |           \ depends on test.com.seventytwomiles.services
    |
    -- test.com.seventytwomiles.model depends on
    |  |
    |  |-- test.com.seventytwomiles.services
    |     |-- @ Person.java
    |        \ while
    |         |-- PersonService.java
    |         |-- PersonServiceImpl.java
    |           \ depends on test.com.seventytwomiles.model
    |
    -- org.architecturerules.domain depends on
    |  |
    |  |-- org.architecturerules.exceptions
    |     |-- @ RuleTest.java
    |        \ while
    |         |-- IllegalArchitectureRuleExceptionTest.java
    |         |-- DependencyConstraintExceptionTest.java
    |         |-- NoPackagesFoundExceptionTest.java
    |         |-- SourceNotFoundExceptionTest.java
    |           \ depends on org.architecturerules.domain
    |
    -- test.com.seventytwomiles.dao.hibernate depends on
    |  |
    |  |-- test.com.seventytwomiles.services
    |     |-- @ PersonDaoImpl.java
    |        \ while
    |         |-- PersonServiceImpl.java
    |           \ depends on test.com.seventytwomiles.dao.hibernate
    |
   
    at org.architecturerules.services.CyclicRedundancyServiceImpl.buildCyclicRedundancyException(CyclicRedundancyServiceImpl.java:127)
    at org.architecturerules.services.CyclicRedundancyServiceImpl.performCyclicRedundancyCheck(CyclicRedundancyServiceImpl.java:116)
    at org.architecturerules.services.CyclicRedundancyServiceTest.testPerformCyclicRedundancyCheck(CyclicRedundancyServiceTest.java:93)

I guess I will set the issue to "Started" until I get the meta data fixed. Then I will update to solved.

~ Mike Nereson
Reply all
Reply to author
Forward
0 new messages