Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reporters not working #3

Open
antonjahn opened this issue Jan 14, 2025 · 3 comments · May be fixed by #4
Open

Reporters not working #3

antonjahn opened this issue Jan 14, 2025 · 3 comments · May be fixed by #4

Comments

@antonjahn
Copy link

Hi @rdmueller, interesting project you started here! This is the repo I found searching for asciidoc linter.

When running on a file with findings, the current version is failing with errors like:

~/.../doc/process/build_management$ asciidoc-lint --format console external_dependencies.adoc 
Error processing external_dependencies.adoc: 'Finding' object has no attribute 'line'

The issue maybe inconsistent classes/types. The reporters think they get LintReport (aka List LintError), while in fact they get List[Findings]. So either some processing step is skipped, or the reporters should use finding.position.line.

class ConsoleReporter(Reporter):
    """Reports findings in console format with colors"""
    
    def format_report(self, report: LintReport) -> str:
        """Format the report with ANSI colors"""
        if not report.errors:
            return "\033[32m✓ No issues found\033[0m"
            
        output = []
        print(report.errors)   # added by me, drops findings
        for error in report.errors:
            location = f"\033[36mline {error.line}\033[0m"   # issue at hand, error isinstance Finding, not LintError
            if hasattr(error, "file"):
                location = f"\033[36m{error.file}:{location}\033[0m"
            
            output.append(f"\033[31m✗\033[0m {location}: {error.message}")
@rdmueller
Copy link
Member

Hey, cool that you found this project!
Did you notice that it was fully coded and set up by GenAI? So let's see how GenAI will fix your issue...

rdmueller added a commit that referenced this issue Jan 14, 2025
Fixes #3

Update `ConsoleReporter` class to correctly handle findings and display their positions.

* Change `ConsoleReporter` class in `asciidoc_linter/reporter.py` to use `error.position.line` instead of `error.line` to correctly access the line number.
* Ensure `ConsoleReporter` class correctly handles the `position` attribute of `Finding` instances.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/docToolchain/asciidoc-linter/issues/3?shareId=XXXX-XXXX-XXXX-XXXX).
@rdmueller rdmueller linked a pull request Jan 14, 2025 that will close this issue
@rdmueller
Copy link
Member

Do you think the PR could fix the issue?

@A-n-d-y-K
Copy link

Dear @rdmueller ,
I´m able to reproduce the issue reported by @antonjahn. When applying your fix in PR #4

(.venv) PS C:\Projects\Repo\asciidoc-linter> asciidoc-linter test.adoc Error processing test.adoc: 'Finding' object has no attribute 'file' (.venv) PS C:\Projects\Repo\asciidoc-linter>

content of test.adoc

= AsciiDoc Article Title

Some text

== Header 2

asef

Test Environment
windows 11, Python 3.13.1

Additional findings
setup.py line 34 is long_description=open('README.adoc').read(),
setup.py line 34 may long_description=open('README.adoc', encoding='utf-8').read(),

README.adoc line 90 is pip install .
README.adoc line 90 may pip install -e .

README.adoc line 100, 103, 106 is asciidoc-lint ...
README.adoc line 100, 103, 106 may asciidoc-linter ...

Why I´m here?
Curiousity Folge 242

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants