Uploaded image for project: 'SonarPHP'
  1. SonarPHP
  2. SONARPHP-40

Common PHP filenames in multiple source of test derectories

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.4
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      If a project consists of multiple source directories, or a source directory and a test directory, and these directories have files with same names, sonar can't import these projects, because these files are considered as a same files, which causes an exception.

      For example:

      Source code folder (application):

      • Bootrstrap.php
      • Module1/
        • Class1.php
        • Class2.php
      • Module2/
        • Class1.php
        • Class2.php
        • Class3.php

      and a UnitTests folder (tests):

      • Bootrstrap.php
      • Module1/
        • Class1Test.php
        • Class2Test.php
      • Module2/
        • Class1Test.php
        • Class2Test.php
        • Class3.php

      The Bootstrap.php file has problems:

       
      Embedded error: PhpFile[filename=Bootstrap,longName=Bootstrap,packageKey=(default),parent=org.sonar.plugins.php.core.PhpPackage@51184a30,unitTest=true]
      [INFO] ------------------------------------------------------------------------
      [INFO] Trace
      org.apache.maven.lifecycle.LifecycleExecutionException: Can not execute Sonar
      	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:583)
      	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:512)
      	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:482)
      	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
      	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:227)
      	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
      	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
      	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
      	at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
      	at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
      	at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
      	at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
      Caused by: org.apache.maven.plugin.MojoExecutionException: Can not execute Sonar
      	at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:103)
      	at org.codehaus.mojo.sonar.Bootstraper.start(Bootstraper.java:79)
      	at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:88)
      	at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
      	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
      	... 16 more
      Caused by: org.sonar.api.resources.DuplicatedSourceException: PhpFile[filename=Bootstrap,longName=Bootstrap,packageKey=(default),parent=org.sonar.plugins.php.core.PhpPackage@51184a30,unitTest=true]
      	at org.sonar.batch.index.SourcePersister.saveSource(SourcePersister.java:45)
      	at org.sonar.batch.index.DefaultPersistenceManager.setSource(DefaultPersistenceManager.java:78)
      	at org.sonar.batch.index.DefaultIndex.setSource(DefaultIndex.java:407)
      	at org.sonar.batch.DefaultSensorContext.saveSource(DefaultSensorContext.java:159)
      	at org.sonar.plugins.php.core.PhpSourceImporter.parseDirs(PhpSourceImporter.java:143)
      	at org.sonar.plugins.php.core.PhpSourceImporter.doAnalyse(PhpSourceImporter.java:128)
      	at org.sonar.plugins.php.core.PhpSourceImporter.analyse(PhpSourceImporter.java:76)
      	at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:58)
      	at org.sonar.batch.phases.Phases.execute(Phases.java:80)
      	at org.sonar.batch.ProjectBatch.execute(ProjectBatch.java:59)
      	at org.sonar.batch.Batch.analyzeModule(Batch.java:164)
      	at org.sonar.batch.Batch.analyzeModules(Batch.java:82)
      	at org.sonar.batch.Batch.execute(Batch.java:62)
      	at org.sonar.maven.SonarMojo.executeBatch(SonarMojo.java:155)
      	at org.sonar.maven.SonarMojo.execute(SonarMojo.java:144)
      	at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
      	at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:98)
      	... 20 more
      

      The same concerns Class3.php

      The reason of exception is that Resource Key is internally represented as a relative path to a file.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              Anonymous Anonymous
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: