Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#1 reporting

African ungulates
closed
Paul Cantrell
Output (4)
3
2003-08-05
2003-04-03
Anonymous
No

Hello,

I'm not using your project but I'm looking to use it. I
looked at JDepend but something was missing :
automatic rules.

I've got exactly the problem you are describing : a lot of
developpers, some are "artist" that don't bother with
packaging rules... But I'd like to get reports on rules
breaker. But for what I read, your logs are really brute :
some class violates some rules. I'd like to get more
reason on why and some summary on package level.

Do you thing it you be hard to adapt your source code to
do somthing like that ? I'm ready to do it if you estimate
that it could be done in some days (and in a generic
way to add it in your tool)

thank you for looking at it,

Stéphan

mestachs@hotmail.com

Discussion

  • Paul Cantrell
    Paul Cantrell
    2003-04-29

    Logged In: YES
    user_id=41726

    Future versions of Macker will provide more details about exactly where and how one class references another, including a source line number where possible.

    There's been some discussion of providing XML output, would would provide for more flexible reporting. You might be able to use that for package-level summary and the like.

    All of that will take a back seat to functional development of rules and patterns until Macker 0.6 or thereabouts.

     
  • Paul Cantrell
    Paul Cantrell
    2003-04-29

    • labels: --> Output
    • priority: 5 --> 3
    • assigned_to: nobody --> melquiades
    • milestone: --> African ungulates
    • status: open --> pending
     
  • Paul Cantrell
    Paul Cantrell
    2003-04-29

    • status: pending --> open
     
  • Paul Cantrell
    Paul Cantrell
    2003-08-05

    • status: open --> closed
     
  • Paul Cantrell
    Paul Cantrell
    2003-08-05

    Logged In: YES
    user_id=41726

    I just checked in a prototype of an XML report feature. The
    report doesn't contain any more information than what's already
    there -- just "class X accesses class Y" -- but you might be able
    to parse the output to give you the package-level rollup you're
    looking for.

    If you can post an example of specific rollup behavior you'd like
    to see to the developer mailing list, it might generate discussion.

     
  • Paul Cantrell
    Paul Cantrell
    2003-08-25

    Logged In: YES
    user_id=41726

    Scott's original implementation, for bookkeeping purposes:

    From: Scott Sayles
    Date: Mon Jun 30, 2003

    My apologies for not getting to this sooner, but I've been on
    vacation.

    Attached is a patch file containing the changes made to the
    Macker main
    class and the source file for XMLReportListener.

    It was a quick hack but it works. Essentially, I had to create
    and maintain a BufferedWriter and XMLReportListener outside
    of the rule set checking loop in the check method in Macker.
    I've also added a new command line parameter -w|--writetofile
    that will tell Macker to generate the xml report in a file named
    macker-report.xml. The output file can be configured
    programmatically.

    Here's a sample of the XML:

    <macker-report>
    <rule-set name="no domain in swingclient">
    </rule-set>
    <rule-set name="no PAL in swingclient">
    <acess-violation>
    <description>Illegal reference
    from com.fgm.tracker.swingclient.SearchCriteriaDialog
    to com.fgm.pal.QueryCriterion</description>

    <from>com.fgm.tracker.swingclient.SearchCriteriaDialog</
    from>
    <to>com.fgm.pal.QueryCriterion</to>
    </acess-violation>
    <acess-violation>
    <description>Illegal reference
    from com.fgm.tracker.swingclient.SearchCriterionPanel
    to com.fgm.pal.QueryCriterion</description>

    <from>com.fgm.tracker.swingclient.SearchCriterionPanel</
    from>
    <to>com.fgm.pal.QueryCriterion</to>
    </acess-violation>
    </rule-set>
    <rule-set name="no domain in domainapi">
    </rule-set>
    </macker-report>
    ======================================

    Let me know what you think.

    Scott

    Index: src/net/innig/macker/Macker.java

    ====================
    RCS file: /cvsroot/macker/macker/src/net/innig/macker/
    Macker.java,v
    retrieving revision 1.29
    diff -r1.29 Macker.java
    28a29
    import java.io.BufferedWriter;
    29a31
    import java.io.FileWriter;
    102a105,106
    else if(args[arg].equals("-w") || args[arg].equals("--
    writetofile"))
    macker.setReportFile(new File("macker-
    report.xml"));
    133c137
    < System.out.println(" macker [-V|--version] [-v|--
    verbose] [-D var=value]* [-r rulesfile]* classes");
    ---
    System.out.println(" macker [-V|--version] [-v|--verbose]
    [-w|--writetofile] [-D var=value]* [-r rulesfile]* classes");
    224a229,236
    public void setReportFile(File outputFile)
    {
    reportFile = outputFile;
    writeToXML = true;
    }

    public boolean writeToXML()
    { return writeToXML; }
    267a280,299

    // prepare the XMLReportListener
    XMLReportListener reportListener = null;
    BufferedWriter bw = null;
    if (writeToXML())
    {
    try
    {
    bw = new BufferedWriter(new FileWriter(reportFile));
    reportListener = new XMLReportListener(bw);
    reportListener.init();
    }
    catch (IOException ioe)
    {
    System.out.println("Exception occurred while trying
    to write to file "+
    reportFile.getName() +" : "+ ioe);
    return;
    }
    }

    290a323,326

    if (writeToXML())
    context.addListener(reportListener);

    292a329,345

    if (writeToXML())
    {
    try
    {
    reportListener.finish();
    bw.flush();
    bw.close();
    }
    catch (IOException ioe)
    {
    System.out.println("Exception occurred while trying
    to write to file "+
    reportFile.getName() +" : "+ ioe);
    return;
    }
    }

    300a354,355
    private boolean writeToXML;
    private File reportFile;
    /*
    * Created on Jun 20, 2003
    *
    * To change the template for this generated file go to
    * Window>Preferences>Java>Code Generation>Code and
    Comments
    */
    package net.innig.macker.event;

    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.io.Writer;
    import java.text.DateFormat;
    import java.util.Date;
    import java.util.Locale;

    import org.apache.xml.serialize.LineSeparator;

    import net.innig.macker.rule.RuleSet;

    /**
    *
    *
    */
    public class XMLReportListener implements
    MackerEventListener {

    private PrintWriter out;

    public XMLReportListener(Writer writer) {
    out = new PrintWriter(writer);
    }

    /* (non-Javadoc)
    * @see
    net.innig.macker.event.MackerEventListener#mackerStarted(n
    et.innig.macker.rule.RuleSet)
    */
    public void mackerStarted(RuleSet ruleSet) {
    out.println(" <rule-set name=\"" + ruleSet.getName()
    +"\">");

    }

    /* (non-Javadoc)
    * @see
    net.innig.macker.event.MackerEventListener#mackerFinished(
    net.innig.macker.rule.RuleSet)
    */
    public void mackerFinished(RuleSet ruleSet) throws
    MackerIsMadException {
    out.println(" </rule-set>");
    }

    /* (non-Javadoc)
    * @see
    net.innig.macker.event.MackerEventListener#mackerAborted(
    net.innig.macker.rule.RuleSet)
    */
    public void mackerAborted(RuleSet ruleSet) { }

    /* (non-Javadoc)
    * @see
    net.innig.macker.event.MackerEventListener#handleMackerEv
    ent(net.innig.macker.rule.RuleSet,
    net.innig.macker.event.MackerEvent)
    */
    public void handleMackerEvent(RuleSet ruleSet,
    MackerEvent event)
    throws MackerIsMadException {

    if (event instanceof AccessRuleViolation) {
    AccessRuleViolation violation =
    (AccessRuleViolation)event;

    out.println(" <acess-violation>");
    out.print( " <description>"+
    violation.getDescription());
    out.println("</description>");
    out.println(" <from>"+
    violation.getFrom().getClassName() +"</from>");
    out.println(" <to>"+
    violation.getTo().getClassName() +"</to>");
    out.println(" </acess-violation>");
    }
    }

    public void init() {
    out.println("<macker-report>");
    }

    public void finish() {
    out.println("</macker-report>");
    }
    }