Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[e4-dev] Running Findbugs

Hi,

Out of curiosity I've been running find bugs on our code base and here
are the stats:

org.eclipse.e4.core.contexts (3)
org.eclipse.e4.core.di (6)
org.eclipse.e4.core.di.extensions (1)
org.eclipse.e4.core.services (2)
org.eclipse.e4.core.tests.services (41)
org.eclipse.e4.core.tests.services.annotations (23)
org.eclipse.e4.core.tests.services.atinject (2)
org.eclipse.e4.demo.contacts (1)
org.eclipse.e4.demo.e4photo (8)
org.eclipse.e4.demo.e4photo.flickr.service.rest (2)
org.eclipse.e4.pde.webui (5)
org.eclipse.e4.tools.emf.editor (1)
org.eclipse.e4.tools.emf.editor3x (3)
org.eclipse.e4.tools.emf.liveeditor (2)
org.eclipse.e4.tools.emf.ui (10)
org.eclipse.e4.tools.ui.designer (45)
org.eclipse.e4.ui.bindings (4)
org.eclipse.e4.ui.bindings.tests (2)
org.eclipse.e4.ui.compatibility.tests (6)
org.eclipse.e4.ui.css.core (24)
org.eclipse.e4.ui.css.swt (13)
org.eclipse.e4.ui.gadgets (2)
org.eclipse.e4.ui.model.workbench (71)
org.eclipse.e4.ui.model.workbench.edit (19)
org.eclipse.e4.ui.services (1)
org.eclipse.e4.ui.tests (30)
org.eclipse.e4.ui.web (4)
org.eclipse.e4.ui.workbench (5)
org.eclipse.e4.ui.workbench.renderers.swt (8)
org.eclipse.e4.ui.workbench.swt (7)
org.eclipse.e4.xwt (100)
org.eclipse.e4.xwt.css (1)
org.eclipse.e4.xwt.pde (3)
org.eclipse.e4.xwt.tools.ui (12)
org.eclipse.e4.xwt.tools.ui.designer (93)
org.eclipse.e4.xwt.tools.ui.designer.core (33)
org.eclipse.e4.xwt.tools.ui.editor (37)
org.eclipse.e4.xwt.tools.ui.imagecapture (14)
org.eclipse.e4.xwt.tools.ui.palette (13)
org.eclipse.e4.xwt.tools.ui.xaml (14)
org.eclipse.e4.xwt.ui.workbench (1)
org.eclipse.e4.xwt.vex (37)
org.eclipse.platform (1)
===================================================
Overall bugs count: 710

And it reveals fairly cool bugs like this possible NPE in InjectorImpl:
--------------8<-------------------
> private void processClassHierarchy(Object userObject, AbstractObjectSupplier objectSupplier, boolean processStatic, boolean track, boolean normalOrder, List<Requestor> requestors) {
> 		processClass(userObject, objectSupplier, (userObject == null) ? null : userObject.getClass(), new ArrayList<Class<?>>(5), processStatic, track, normalOrder, requestors);
> 	}
> 
> 	/**
> 	 * Make the processor visit all declared members on the given class and all superclasses
> 	 */
> 	private void processClass(Object userObject, AbstractObjectSupplier objectSupplier, Class<?> objectsClass, ArrayList<Class<?>> classHierarchy, boolean processStatic, boolean track, boolean normalOrder, List<Requestor> requestors) {
> 		// order: superclass, fields, methods
> 		if (objectsClass != null) {
> 			Class<?> superClass = objectsClass.getSuperclass();
> 			if (!superClass.getName().equals(JAVA_OBJECT)) {
> 				classHierarchy.add(objectsClass);
> 				processClass(userObject, objectSupplier, superClass, classHierarchy, processStatic, track, normalOrder, requestors);
> 				classHierarchy.remove(objectsClass);
> 			}
> 		}
> 		if (normalOrder) {
> 			processFields(userObject, objectSupplier, objectsClass, processStatic, track, requestors);
> 			processMethods(userObject, objectSupplier, objectsClass, classHierarchy, processStatic, track, requestors);
> 		} else {
> 			processMethods(userObject, objectSupplier, objectsClass, classHierarchy, processStatic, track, requestors);
> 			processFields(userObject, objectSupplier, objectsClass, processStatic, track, requestors);
> 		}
> 	}
> 
> 	/**
> 	 * Make the processor visit all declared fields on the given class.
> 	 */
> 	private void processFields(Object userObject, AbstractObjectSupplier objectSupplier, Class<?> objectsClass, boolean processStatic, boolean track, List<Requestor> requestors) {
> 		Field[] fields = objectsClass.getDeclaredFields();
--------------8<-------------------

Which will lead to an NPE in the last line if userObject = null in the
2nd :-)

Tom

-- 
B e s t S o l u t i o n . a t                        EDV Systemhaus GmbH
------------------------------------------------------------------------
tom schindl                                        geschaeftsfuehrer/CEO
------------------------------------------------------------------------
eduard-bodem-gasse 5/1    A-6020 innsbruck      phone    ++43 512 935834


Back to the top