jQAssistant Demos

Beispiel-Queries

Setup

Cypher Extension für Jupyter laden


In [1]:
%load_ext cypher

Klasse mit den meisten Methoden auflisten


In [2]:
%%cypher
MATCH 
  (t:Type)-[:DECLARES]->(m:Method)
RETURN t.fqn as Typ, COUNT(m) as Methoden
ORDER BY Methoden DESC


151 rows affected.
Out[2]:
Typ Methoden
org.springframework.samples.petclinic.model.Owner 21
org.springframework.samples.petclinic.model.Pet 16
org.springframework.samples.petclinic.web.OwnerControllerTests 13
org.springframework.samples.petclinic.service.AbstractClinicServiceTests 12
org.springframework.samples.petclinic.model.Vet 11
org.springframework.samples.petclinic.service.ClinicServiceImpl 11
org.springframework.samples.petclinic.model.Visit 10
org.springframework.samples.petclinic.repository.jdbc.JdbcPet 10
org.springframework.samples.petclinic.service.ClinicService 9
org.springframework.samples.petclinic.web.OwnerController 9
org.springframework.samples.petclinic.web.PetController 9
org.springframework.samples.petclinic.PetclinicInitializer 8
org.springframework.samples.petclinic.web.PetControllerTests 8
org.springframework.samples.petclinic.repository.jdbc.JdbcOwnerRepositoryImpl 7
org.springframework.samples.petclinic.util.CallMonitoringAspect 7
org.springframework.samples.petclinic.repository.jdbc.JdbcPetVisitExtractor 7
org.assertj.core.api.Assertions 7
org.springframework.samples.petclinic.web.PetTypeFormatterTests 6
org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate 6
org.springframework.test.web.servlet.result.MockMvcResultMatchers 6
org.springframework.samples.petclinic.web.VisitController 6
org.springframework.test.web.servlet.result.ModelResultMatchers 6
org.springframework.samples.petclinic.web.VisitControllerTests 6
org.springframework.samples.petclinic.web.VetControllerTests 5
java.util.Collection 5
org.springframework.samples.petclinic.model.Person 5
org.springframework.samples.petclinic.web.PetTypeFormatter 5
org.springframework.samples.petclinic.repository.jdbc.JdbcPetRepositoryImpl 5
java.util.List 5
org.springframework.samples.petclinic.repository.PetType 5
java.sql.ResultSet 5
java.lang.StringBuilder 5
org.springframework.jdbc.core.simple.SimpleJdbcInsert 4
org.springframework.util.StopWatch 4
org.springframework.samples.petclinic.util.BrokenSingleton 4
org.springframework.samples.petclinic.repository.jdbc.JdbcVisitRepositoryImpl 4
org.springframework.web.context.support.XmlWebApplicationContext 4
org.springframework.samples.petclinic.model.BaseEntity 4
org.springframework.samples.petclinic.model.NamedEntity 4
javax.persistence.EntityManager 4
org.springframework.core.style.ToStringCreator 4
org.springframework.samples.petclinic.model.Specialty 4
org.springframework.samples.petclinic.repository.jpa.JpaPetRepositoryImpl 4
org.springframework.samples.petclinic.repository.jpa.JpaOwnerRepositoryImpl 4
org.springframework.samples.petclinic.web.PetValidator 3
org.springframework.samples.petclinic.model.ValidatorTests 3
org.springframework.samples.petclinic.web.VetController 3
org.springframework.samples.petclinic.repository.jdbc.JdbcPetRowMapper 3
org.springframework.samples.petclinic.util.Database 3
javax.persistence.Query 3
org.springframework.samples.petclinic.repository.jpa.JpaVisitRepositoryImpl 3
org.springframework.samples.petclinic.repository.OwnerRepository 3
org.springframework.samples.petclinic.repository.PetRepository 3
org.springframework.web.servlet.support.AbstractDispatcherServletInitializer 3
java.lang.Integer 3
java.util.Set 3
org.springframework.samples.petclinic.util.RecursiveDbCallsExample 3
org.springframework.test.web.servlet.setup.StandaloneMockMvcBuilder 3
java.lang.Class 3
org.springframework.samples.petclinic.repository.jdbc.JdbcVisitRowMapper 3
org.springframework.samples.petclinic.repository.jdbc.JdbcVetRepositoryImpl$1 3
org.springframework.samples.petclinic.util.SomeWeirdRecursiveDataStructure 3
org.joda.time.LocalDate 3
org.springframework.samples.petclinic.web.CrashControllerTests 3
org.springframework.samples.petclinic.util.EntityUtils 2
org.springframework.test.web.servlet.request.MockMvcRequestBuilders 2
org.springframework.test.web.servlet.result.StatusResultMatchers 2
org.assertj.core.api.AbstractCharSequenceAssert 2
java.util.ArrayList 2
org.springframework.validation.beanvalidation.LocalValidatorFactoryBean 2
java.lang.String 2
org.springframework.web.servlet.ModelAndView 2
java.util.logging.Logger 2
org.springframework.samples.petclinic.web.PetTypeFormatterTests$2 2
org.springframework.jdbc.core.BeanPropertyRowMapper 2
org.springframework.jdbc.core.namedparam.MapSqlParameterSource 2
org.springframework.samples.petclinic.util.RecursiveClass 2
org.springframework.samples.petclinic.repository.jdbc.JdbcVetRepositoryImpl 2
org.springframework.test.web.servlet.result.ContentResultMatchers 2
org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder 2
org.assertj.core.api.AbstractIntegerAssert 2
org.springframework.validation.BindingResult 2
org.springframework.samples.petclinic.model.Vets 2
org.hamcrest.Matchers 2
org.aspectj.lang.ProceedingJoinPoint 2
org.springframework.samples.petclinic.web.PetTypeFormatterTests$1 2
java.util.Iterator 2
org.springframework.samples.petclinic.web.CrashController 2
java.lang.Object 2
org.springframework.samples.petclinic.repository.jpa.JpaVetRepositoryImpl 2
org.springframework.jdbc.core.JdbcTemplate 2
javax.servlet.ServletRegistration$Dynamic 2
javax.validation.ConstraintViolation 2
org.springframework.samples.petclinic.repository.VisitRepository 2
org.springframework.samples.petclinic.repository.springdatajpa.SpringDataOwnerRepository 2
org.springframework.web.bind.WebDataBinder 2
org.springframework.samples.petclinic.service.ClinicServiceSpringDataJpaTests 1
org.assertj.core.api.AbstractComparableAssert 1
com.github.dandelion.datatables.core.web.filter.DatatablesFilter 1
org.springframework.orm.ObjectRetrievalFailureException 1
org.springframework.samples.petclinic.service.ClinicServiceJpaTests 1
java.lang.Number 1
javax.servlet.FilterRegistration$Dynamic 1
org.springframework.samples.petclinic.architecture.MixedBoundedContexts 1
com.github.dandelion.core.web.DandelionFilter 1
java.lang.Thread 1
java.util.HashMap 1
org.mockito.stubbing.OngoingStubbing 1
java.text.ParseException 1
org.springframework.beans.support.PropertyComparator 1
org.springframework.ui.ModelMap 1
org.springframework.samples.petclinic.architecture.ActualTechnicalAspect 1
org.springframework.samples.petclinic.repository.springdatajpa.SpringDataPetRepository 1
org.springframework.test.web.servlet.result.JsonPathResultMatchers 1
java.util.Map 1
org.springframework.test.web.servlet.result.ViewResultMatchers 1
org.hamcrest.xml.HasXPath 1
org.springframework.core.env.ConfigurableEnvironment 1
org.springframework.context.i18n.LocaleContextHolder 1
org.junit.Assert 1
java.util.HashSet 1
org.springframework.data.jdbc.core.OneToManyResultSetExtractor 1
java.lang.RuntimeException 1
org.assertj.core.util.Lists 1
org.springframework.test.web.servlet.ResultActions 1
com.github.dandelion.core.web.DandelionServlet 1
org.springframework.beans.support.MutableSortDefinition 1
org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource 1
org.springframework.format.support.FormattingConversionServiceFactoryBean 1
org.mockito.Mockito 1
java.lang.UnsupportedOperationException 1
org.assertj.core.api.AbstractObjectAssert 1
org.springframework.ui.Model 1
org.mockito.BDDMockito 1
org.springframework.test.web.servlet.MockMvc 1
org.springframework.samples.petclinic.architecture.Pattern 1
org.springframework.test.web.servlet.setup.MockMvcBuilders 1
org.springframework.samples.petclinic.repository.VetRepository 1
javax.validation.Validator 1
javax.servlet.ServletContext 1
org.mockito.BDDMockito$BDDMyOngoingStubbing 1
org.assertj.core.api.AbstractBooleanAssert 1
org.springframework.samples.petclinic.service.ClinicServiceJdbcTests 1
java.util.EnumSet 1
java.util.Collections 1
org.springframework.samples.petclinic.architecture.BoundedContext 1
org.assertj.core.api.AbstractLongAssert 1
org.springframework.util.StringUtils 1
org.springframework.web.filter.CharacterEncodingFilter 1
org.springframework.validation.Errors 1
org.springframework.samples.petclinic.architecture.ActualSubdomain 1

Statische, geschriebene Variablen


In [3]:
%%cypher
MATCH (c:Class)-[:DECLARES]->(f:Field)<-[w:WRITES]-(m:Method)
WHERE 
    EXISTS(f.static) AND NOT EXISTS(f.final)
RETURN 
    c.name as InClass, 
    m.name as theMethod, 
    w.lineNumber as writesInLine, 
    f.name as toStaticField


3 rows affected.
Out[3]:
InClass theMethod writesInLine toStaticField
OwnerController processFindForm 112 ownersIndexes
OwnerController processFindForm 112 ownersIndexes
BrokenSingleton getInstance 11 INSTANCE

Aggregation von Messergebnissen über fachliche Bereiche


In [4]:
%%cypher
MATCH 
  (t:Type)-[:BELONGS_TO]->(s:Subdomain),
  (t)-[:HAS_CHANGE]->(ch:Change)
RETURN 
  s.name as ASubdomain,
  COUNT(DISTINCT t) as Types,
  COUNT(DISTINCT ch) as Changes
ORDER BY Types DESC


8 rows affected.
Out[4]:
ASubdomain Types Changes
crossfunctional 19 114
Pet 15 208
Visit 9 119
Vet 8 117
Owner 7 130
Clinic 6 102
Person 1 5
Specialty 1 7

Umfassende Aggregation von Messergebnissen über fachliche Bereiche


In [5]:
%%cypher
MATCH 
  (t:Type)-[:BELONGS_TO]->(s:Subdomain),
  (t)-[:HAS_CHANGE]->(ch:Change),
  (t)-[:HAS_MEASURE]->(co:Coverage)
OPTIONAL MATCH
  (t)-[:HAS_BUG]->(b:BugInstance)
RETURN 
  s.name as ASubdomain,
  COUNT(DISTINCT t) as Types,
  COUNT(DISTINCT ch) as Changes,
  AVG(co.ratio) as Coverage,
  COUNT(DISTINCT b) as Bugs,
  SUM(DISTINCT t.lastMethodLineNumber) as Lines
ORDER BY Coverage ASC, Bugs DESC


8 rows affected.
Out[5]:
ASubdomain Types Changes Coverage Bugs Lines
Vet 5 80 0.17041666666666666 0 324
Visit 6 96 0.36914062500000017 0 484
Pet 10 172 0.46277559649652694 1 736
crossfunctional 7 62 0.5188034188034185 4 309
Owner 4 103 0.5375584415584417 4 539
Clinic 1 19 0.8888888888888888 0 115
Person 1 5 1.0 0 53
Specialty 1 7 1.0 0 32