Menu

#1248 global rule management persistence broken

Eclipse-Plugin
closed
None
Eclipse
2-Critical
Bug
2015-02-19
2014-08-20
No

There is something seriously wrong with the "global rule management" persistence.

When I shutdown and restart Eclipse, and then re-run PMD on my project, various rules that I have configured off suddenly become active again.

This is even though they are unticked in the "global rule management" panel.

I have to tick them and then untick them to make them go off properly.

This seems to happen on every restart, and which rules it affects seems a little random.

Related

Issues: #1312

Discussion

  • Andreas Dangel

    Andreas Dangel - 2014-09-09
    • status: open --> more-info-needed
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> Eclipse-Plugin
     
  • Andreas Dangel

    Andreas Dangel - 2014-09-09

    I just released a new version of the plugin. Can you try, whether this issue is now solved?
    I'm asking, because this might be a duplicate of [#1184].
    Thanks!

     

    Related

    Issues: #1184

  • Clément Boudet

    Clément Boudet - 2014-11-12

    Hello,

    I had a similar problem with 4.0.3 and updated to 4.0.5 to check if it was corrected. Unfortunately it's not.

    I am trying to package a preconfigured development environment for our teams. Eclipse and an empty workspace, basically. I deleted all default rules to then import a custom ruleset in "global rule management" configuration. Problem is, after restarting Eclipse the default configuration is back.

    Could the lack of project in the workspace be responsible ?

    Addendum :
    The problem only appears if the rules are imported by copy. Import by reference works fine.

     

    Last edit: Clément Boudet 2014-11-13
  • Andreas Dangel

    Andreas Dangel - 2014-11-15

    Hi,
    could you send me the following files? In these files, the plugin will store the configuration...

    • ${workspace}/.metadata/.plugins/net.sourceforge.pmd.eclipse.plugin/ruleset.xml
      ** This is where the copied rules would be stored
    • ${workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings/net.sourceforge.pmd.eclipse.plugin.prefs
      ** This is where the activated/selected rules would be stored

    Maybe even two versions of each file: one just before restarting eclipse, and one after restarting eclipse.

     
  • Clément Boudet

    Clément Boudet - 2014-11-17

    Hello,
    Thank you for the fast response.

    Here are the files you required :

    • Before starting Eclipse, with a workspace never configured for PMD
    • After rules import in Eclipse
    • After restarting Eclipse
     
  • Clément Boudet

    Clément Boudet - 2014-11-17

    It seems to be a problem while copying the ruleset. I replaced it in the metadata while Eclipse was closed and after launch the configuration was correct.

     
  • Clément Boudet

    Clément Boudet - 2015-02-11

    Hello,
    Any news on this subject ? Do you need additional information ?

     
  • Andreas Dangel

    Andreas Dangel - 2015-02-15

    Hi!
    Sorry, I didn't have time to look into this issue yet. Hope, I will come by this issue soon.
    Thanks!

     
  • Andreas Dangel

    Andreas Dangel - 2015-02-17

    Hi Clément,
    I've now created a new version. Can you try this out?
    Please use this update site: https://sourceforge.net/projects/pmd/files/pmd-eclipse/update-site-latest/

    I'm afraid, I still don't understand your problem, though. I fixed, the problem, that in ${workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings/net.sourceforge.pmd.eclipse.plugin.prefs where still the old active rules (the rules you deleted), but that should not have been a problem.

    I tried to reproduce your problem, but failed. This is what I did:

    1. Start eclipse with a fresh workspace
    2. Window/Preferences/PMD/Rule Configuration
      a) Enable Global Rule Management
      b) Click into the table widget, then press "CTRL+A" to select all entries
      c) Click the delete rule button
      d) Now I have all rules removed
    3. Click the Import Rule set button
      a) select your ruleset file via the "Browse..." button
      b) select "Import By Copy"
      c) All checkboxes should be checked automatically
      d) Click "ok" - the rule table should be filled, no rule is checked
    4. Now click "Check all rules" (or select the rules you want to have active)
    5. Close the Preferences Dialog with "Ok" - answer "yes" to the question whether rebuild

    After I have restarted eclipse and opened the preferences page again, I see exactly the same rules checked, that I checked before.

    Did you do the same steps? Did you do less/more/different steps? Did you do the steps in a different order?
    What exactly do you mean with "Default Configuration is back"? How do you know that the configuration you see is not your configuration?

    One note on:

    The problem only appears if the rules are imported by copy.
    Import by reference works fine.

    I have no clue, why import by reference works better. In your case, as you want to package the workspace directory and extract it on different machines, "Import By Copy" is way better -> the plugin will copy the rules into a ruleset.xml file in the workspace. Then you don't need to make sure, that the original ruleset.xml file, from where you have imported the rules, exists on the very same absolute path on the other machines... So, for your use case, I would recommend to use "Import By Copy".

    Let me know, if the problem is already gone with my latest changes.

    Thanks,
    Andreas

     
  • Clément Boudet

    Clément Boudet - 2015-02-18

    Hi Andreas,

    Good news, I found the cause of the problem.

    I was surprised you weren't able to reproduce the problem since I followed the very same steps. I thought of what differed, and saw only one thing : the ruleset file itself.

    I removed part of the rules inside the file and tested the behaviour, to realize it was gone. By trial and error I determined it was a particular rule that caused the problem :

    <rule language="java" name="ReplaceHashTableWithMap" ref="rulesets/java/migrating.xml/ReplaceHashtableWithMap" since="1.0" message="Retourner un interface (List,Map) plutôt qu'une implémentation" externalinfourl="http://sirhen-forge/TODO">
    <description><p>Retourner java.util.Map au lieu de java.util.Hashtable.</p> </description>
    </rule>

    Nothing unusual at first sight... except the name : ReplaceHashTableWithMap. With a capital T, contrary to the standard rule, ReplaceHashtableWithMap. This single letter is causing all this !

    I looked at the rules just after import, and I have ReplaceHashTableWithMap AND ReplaceHashtableWithMap. Seems that the plugin is less forgiving at restart...

    Everything works fine with ReplaceHashtableWithMap in my file.

    Clément

     
    • Andreas Dangel

      Andreas Dangel - 2015-02-19

      Hi Clément,

      many thanks for figuring this out! This was indeed the problem - and it was actually a bug in PMD itself for handling rule references.

      I could fix the problem [#1312] in PMD and integrated it with the eclipse plugin. You can use the update-site to update your version again:
      https://sourceforge.net/projects/pmd/files/pmd-eclipse/update-site-latest/

      I also added a error dialog, in case the stored ruleset couldn't be loaded anymore - because, this is actually what happened: PMD wrote it down but couldn't read it anymore - and the eclipse plugin fell back to loading the default rules again... (the error was actually logged but not displayed - easy to be overlooked).

      I consider this bug as closed now.

      Thanks again!
      Andreas

       

      Related

      Issues: #1312

  • Andreas Dangel

    Andreas Dangel - 2015-02-19
    • status: more-info-needed --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB