@Test public void testBug157() throws PMDException { final IFlexFile file = getTestFiles().get( "bug.FlexPMD157.as" ); final IParserNode ast = FileSetUtils.buildAst( file ); final IClass classNode = NodeFactory.createPackage( ast ).getClassNode(); final ClassMetrics classMetrics = ClassMetrics.create( "bug", new File( file.getFilePath() ), InternalFunctionMetrics.create( new ProjectMetrics(), file.getFullyQualifiedName(), classNode ), classNode, file, 0 ); assertEquals( "<object><name>bug.FlexPMD157</name><ccn>0</ccn><ncss>3</ncss><javadocs>0</javadocs>" + "<javadoc_lines>0</javadoc_lines><multi_comment_lines>0</multi_comment_lines>" + "<single_comment_lines>0</single_comment_lines><functions>0</functions></object>", classMetrics.toXmlString() ); }
public static ClassMetrics create( final String packageFullName, final File fileInPackage, final InternalFunctionMetrics functionMetrics, final IClass classNode, final IFlexFile file, final double mxmlFactor ) { final int average = classNode == null ? 0 : ( int ) Math.round( classNode.getAverageCyclomaticComplexity() ); final int asDocs = ( classNode == null || classNode.getAsDoc() == null ? 0 : MetricUtils.computeNbOfLines( classNode.getAsDoc() .getStringValue() ) ) + ( functionMetrics == null ? 0 : functionMetrics.getAsDocsInClass() ); final int multiLineComments = ( classNode == null ? 0 : MetricUtils.computeMultiLineComments( classNode ) ) + ( functionMetrics == null ? 0 : functionMetrics.getMultipleLineCommentInClass() ); final int nonCommentStatements = computeStatements( functionMetrics, file, mxmlFactor ); return new ClassMetrics( nonCommentStatements, classNode == null ? 0 : classNode.getFunctions().size(), fileInPackage.getName().replace( ".as", "" ).replace( ".mxml", "" ), packageFullName, average, asDocs, multiLineComments, classNode ); }
ClassMetrics extends AbstractNamedMetrics { public static ClassMetrics create( final String packageFullName, final File fileInPackage, final InternalFunctionMetrics functionMetrics, final IClass classNode, final IFlexFile file, final double mxmlFactor ) { final int average = classNode == null ? 0 : ( int ) Math.round( classNode.getAverageCyclomaticComplexity() ); final int asDocs = ( classNode == null || classNode.getAsDoc() == null ? 0 : MetricUtils.computeNbOfLines( classNode.getAsDoc() .getStringValue() ) ) + ( functionMetrics == null ? 0 : functionMetrics.getAsDocsInClass() ); final int multiLineComments = ( classNode == null ? 0 : MetricUtils.computeMultiLineComments( classNode ) ) + ( functionMetrics == null ? 0 : functionMetrics.getMultipleLineCommentInClass() ); final int nonCommentStatements = computeStatements( functionMetrics, file, mxmlFactor ); return new ClassMetrics( nonCommentStatements, classNode == null ? 0 : classNode.getFunctions().size(), fileInPackage.getName().replace( ".as", "" ).replace( ".mxml", "" ), packageFullName, average, asDocs, multiLineComments, classNode ); } }
ClassMetrics extends AbstractNamedMetrics { public static ClassMetrics create( final String packageFullName, final File fileInPackage, final InternalFunctionMetrics functionMetrics, final IClass classNode, final IFlexFile file, final double mxmlFactor ) { final int average = classNode == null ? 0 : ( int ) Math.round( classNode.getAverageCyclomaticComplexity() ); final int asDocs = ( classNode == null || classNode.getAsDoc() == null ? 0 : MetricUtils.computeNbOfLines( classNode.getAsDoc() .getStringValue() ) ) + ( functionMetrics == null ? 0 : functionMetrics.getAsDocsInClass() ); final int multiLineComments = ( classNode == null ? 0 : MetricUtils.computeMultiLineComments( classNode ) ) + ( functionMetrics == null ? 0 : functionMetrics.getMultipleLineCommentInClass() ); final int nonCommentStatements = computeStatements( functionMetrics, file, mxmlFactor ); return new ClassMetrics( nonCommentStatements, classNode == null ? 0 : classNode.getFunctions().size(), fileInPackage.getName().replace( ".as", "" ).replace( ".mxml", "" ), packageFullName, average, asDocs, multiLineComments, classNode ); } private  ClassMetrics( final int nonCommentStatements,
                         final int functionsToBeSet,
                         final String name,
                         final String packageName,
                         final int ccn,
                         final int asDocs,
                         final int multiLineCommentsToBeSet,
                         final IClass classNodeToBeSet ); }
ClassMetrics extends AbstractNamedMetrics { public static ClassMetrics create( final String packageFullName, final File fileInPackage, final InternalFunctionMetrics functionMetrics, final IClass classNode, final IFlexFile file, final double mxmlFactor ) { final int average = classNode == null ? 0 : ( int ) Math.round( classNode.getAverageCyclomaticComplexity() ); final int asDocs = ( classNode == null || classNode.getAsDoc() == null ? 0 : MetricUtils.computeNbOfLines( classNode.getAsDoc() .getStringValue() ) ) + ( functionMetrics == null ? 0 : functionMetrics.getAsDocsInClass() ); final int multiLineComments = ( classNode == null ? 0 : MetricUtils.computeMultiLineComments( classNode ) ) + ( functionMetrics == null ? 0 : functionMetrics.getMultipleLineCommentInClass() ); final int nonCommentStatements = computeStatements( functionMetrics, file, mxmlFactor ); return new ClassMetrics( nonCommentStatements, classNode == null ? 0 : classNode.getFunctions().size(), fileInPackage.getName().replace( ".as", "" ).replace( ".mxml", "" ), packageFullName, average, asDocs, multiLineComments, classNode ); } private  ClassMetrics( final int nonCommentStatements,
                         final int functionsToBeSet,
                         final String name,
                         final String packageName,
                         final int ccn,
                         final int asDocs,
                         final int multiLineCommentsToBeSet,
                         final IClass classNodeToBeSet ); static ClassMetrics create( final String packageFullName,
                                      final File fileInPackage,
                                      final InternalFunctionMetrics functionMetrics,
                                      final IClass classNode,
                                      final IFlexFile file,
                                      final double mxmlFactor ); String getContreteXml(); @Override String getFullName(); int getFunctions(); @Override String getMetricsName(); }
ClassMetrics extends AbstractNamedMetrics { public static ClassMetrics create( final String packageFullName, final File fileInPackage, final InternalFunctionMetrics functionMetrics, final IClass classNode, final IFlexFile file, final double mxmlFactor ) { final int average = classNode == null ? 0 : ( int ) Math.round( classNode.getAverageCyclomaticComplexity() ); final int asDocs = ( classNode == null || classNode.getAsDoc() == null ? 0 : MetricUtils.computeNbOfLines( classNode.getAsDoc() .getStringValue() ) ) + ( functionMetrics == null ? 0 : functionMetrics.getAsDocsInClass() ); final int multiLineComments = ( classNode == null ? 0 : MetricUtils.computeMultiLineComments( classNode ) ) + ( functionMetrics == null ? 0 : functionMetrics.getMultipleLineCommentInClass() ); final int nonCommentStatements = computeStatements( functionMetrics, file, mxmlFactor ); return new ClassMetrics( nonCommentStatements, classNode == null ? 0 : classNode.getFunctions().size(), fileInPackage.getName().replace( ".as", "" ).replace( ".mxml", "" ), packageFullName, average, asDocs, multiLineComments, classNode ); } private  ClassMetrics( final int nonCommentStatements,
                         final int functionsToBeSet,
                         final String name,
                         final String packageName,
                         final int ccn,
                         final int asDocs,
                         final int multiLineCommentsToBeSet,
                         final IClass classNodeToBeSet ); static ClassMetrics create( final String packageFullName,
                                      final File fileInPackage,
                                      final InternalFunctionMetrics functionMetrics,
                                      final IClass classNode,
                                      final IFlexFile file,
                                      final double mxmlFactor ); String getContreteXml(); @Override String getFullName(); int getFunctions(); @Override String getMetricsName();  }