Skip to content

(enrichers/CheckStyle) findings not matching getSourceFile() result on Windows #323

@xsduan

Description

@xsduan

As you know, windows filesystem paths are 'C:\<path\to\project>\<path\in\project>.php' but AbstractUnitObject::getSourceFile() returns 'C:/<path/to/project>/<path/in/project>.php', which means that the indices in CheckStyle.findings[] never match.

I've fixed this temporarily on my machine by adding a str_replace for directory slashes to the enrichUnit() function of src/generator/enricher/checkstyle/CheckStyle.php (and it works!) but since this is a really ugly hack, instead of making a pull request I'm leaving an issue so you can figure out if there's more internals that need to be changed.

Just for reference, my "new" enrichUnit function:

private function enrichUnit(AbstractUnitObject $ctx) {
    $file = $ctx->getSourceFile();
    $file = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $file);
    if (isset($this->findings[$file])) {
        $this->processFindings($ctx->asDom(), $this->findings[$file]);
    }
}

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions