Skip to content

Fixed get_code_region_around_line() boundary issue #81

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

Closed

Conversation

mou23
Copy link

@mou23 mou23 commented Feb 8, 2025

In the get_code_region_around_line() function, line_no is 1-based, so we need to ensure that the last valid line is included in the output.
If line_no + window_size exceeds len(file_content), the current implementation excludes the last line due to the exclusive nature of range(start, end).
To fix this issue, I added 1 to len(file_content), ensuring that the last line is included.

Additionally, i in range(start, end) is 1-based because start and end are derived from line_no, which follows 1-based indexing.
Without adjusting the index in the else block, using file_content[i] would be off by one, potentially leading to an IndexError or retrieving the wrong lines.
To fix this, I replaced file_content[i] with file_content[i - 1]

Verified

This commit was signed with the committer’s verified signature.
targos Michaël Zasso
@mou23 mou23 force-pushed the fix-code-region-around-line branch from 5caf864 to 478b786 Compare February 8, 2025 19:04
@Marti2203
Copy link
Collaborator

Hi, due to the change of licensing, we are going to have to close this PR

@Marti2203 Marti2203 closed this Mar 6, 2025
WangGLJoseph added a commit that referenced this pull request Mar 13, 2025

Verified

This commit was signed with the committer’s verified signature.
targos Michaël Zasso
Marti2203 added a commit that referenced this pull request Mar 25, 2025

Verified

This commit was signed with the committer’s verified signature.
targos Michaël Zasso
* add PyTest framework

* update pytest yml

* update CI

* activate workflow

* fix branch name

* add missing checkout

* add correct docker command

* add sonar source files

* output converage to both term and xml

* use acr-pytest for container name

* Update pytest.yml

* Update sonar-project.properties

* sonar fix and update sonar exclusions

* add coverage file path

* reduce code duplication

* add temp dir in workflow for coverage report

* update sonar config

* use tox and pytest outside container

* add missing tox.ini file

* separate pytest and build workflow

* fix conda env name in workflow

* update shell to use login mode for pytest workflow

* update conda config

* set PYTHONPATH inside tox.ini

* update tox.ini

* include Coverage.py in tox

* add passenv to tox

* change build yaml to only run on PR merge

* remove redundant deps in tox.ini

* abort Sonarqube Scan if coverage.xml is missing

* specify source and test files for sonar

* add test_search_utils

* change build to docker_build

* update tox usage in workflow and documentation

* add test for search_utils.py

* fix get_code_region_around_line

* update testcase (need to clarify class signature)

* fix sonar issues and update README

* add empty test files for search subdir

* add testcase for internal methods of SearchBackend

* update tox.ini for more accurate coverage percentage

* fix test_search_utils

* add tests and add `converage` to whitelist for tox testenv

* update test cases

* update test_saerch_backend

* add testcases for search subdir

* update TESTING.md with setup instructions for adding `conda-forge`

* update tox.ini

* implement fix from PR #81

* Fake error

* Fix failing test

* Fix fake error and add new one

* Update app/data_structures.py

Co-authored-by: autocoderover[bot] <182712390+autocoderover[bot]@users.noreply.github.com>

* Update app/data_structures.py

Co-authored-by: autocoderover[bot] <182712390+autocoderover[bot]@users.noreply.github.com>

* Bump litellm from 1.44.8 to 1.53.1.dev1 (#88)

* Bump litellm from 1.44.8 to 1.53.1.dev1

Bumps [litellm](https://github.com/BerriAI/litellm) from 1.44.8 to 1.53.1.dev1.
- [Release notes](https://github.com/BerriAI/litellm/releases)
- [Commits](BerriAI/litellm@v1.44.8...v1.53.1.dev1)

---
updated-dependencies:
- dependency-name: litellm
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* Update requirements.txt

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Martin Mirchev <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: WangGLJoseph <[email protected]>
Co-authored-by: Martin Mirchev <[email protected]>
Co-authored-by: autocoderover[bot] <182712390+autocoderover[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Marti2203 added a commit that referenced this pull request Mar 26, 2025
* add PyTest framework

* update pytest yml

* update CI

* activate workflow

* fix branch name

* add missing checkout

* add correct docker command

* add sonar source files

* output converage to both term and xml

* use acr-pytest for container name

* Update pytest.yml

* Update sonar-project.properties

* sonar fix and update sonar exclusions

* add coverage file path

* reduce code duplication

* add temp dir in workflow for coverage report

* update sonar config

* use tox and pytest outside container

* add missing tox.ini file

* separate pytest and build workflow

* fix conda env name in workflow

* update shell to use login mode for pytest workflow

* update conda config

* set PYTHONPATH inside tox.ini

* update tox.ini

* include Coverage.py in tox

* add passenv to tox

* change build yaml to only run on PR merge

* remove redundant deps in tox.ini

* abort Sonarqube Scan if coverage.xml is missing

* specify source and test files for sonar

* add test_search_utils

* change build to docker_build

* update tox usage in workflow and documentation

* add test for search_utils.py

* fix get_code_region_around_line

* update testcase (need to clarify class signature)

* fix sonar issues and update README

* add empty test files for search subdir

* add testcase for internal methods of SearchBackend

* update tox.ini for more accurate coverage percentage

* fix test_search_utils

* add tests and add `converage` to whitelist for tox testenv

* update test cases

* update test_saerch_backend

* add testcases for search subdir

* update TESTING.md with setup instructions for adding `conda-forge`

* update tox.ini

* add empty test files for api subdir

* implement fix from PR #81

* Fake error

* Fix failing test

* Fix fake error and add new one

* Update app/data_structures.py

Co-authored-by: autocoderover[bot] <182712390+autocoderover[bot]@users.noreply.github.com>

* update readme

* improve coverage of search_manage.py

* improve coverage for search_utils

* show only analysis cov

* add empty test_sbfl

* remove redundant import stmts

* add test cases for sbfl.py

* run actions on pytest-unit branch

* add testing for api/validation.py

* refactor common test utils and make it a package, add test cases

* ensure coverage on new code

* add test cases for api/eval_helper.py

* enable printing branch coverage on CI

* cover some missing branches in search_backend

* complete coverage for search/search_backend.py

* remove redundant collection

* add test for gpt.py

* update test for catching BadRequestError

* disable pytest output capturing to show stdout

* improve coverage of test_gpt.py

* refactor common test code to pytest_utils

* add unit test for model/claude.py

* remove redundant declaration (refactored into pytest_utils)

* add tests for models

* add tests for azure.py

* test bedrock

* add problematic definition for Sonar scan

* try changing sonar.sources to include test/

* modify sonar scan config

* revert to previous sonar config for showing coverage data

* finish testing models submodule

* add empty test agent files

* update ci

* improve coverage of test_agent_search

* test_patch_utils

* test_agent_reproducer

* test_agent_write_patch

* test_agent_select

* test_agent_reviewer

* test_agent_proxy and refactor DummyModel to pytest_utils

* test main app dir classes

* test_manage

* add unit test for GitHubTask and LocalTask

* test_inference

* move app test files

* add test files

* update build files for osx-arm64 envO

* add app level testing

* add tests for running raw tasks

* improve coverage

* setup multi-env for tox pytest

* update ci yaml

* update ci yaml to refer to github secrets for LLM API keys

* add anthropic integration test (negative case with dummy api key)

* update integration test ci

* integration test with anthropic

* remove logging

* add simple openai integration test

* remove print

* update integration

* update ci branch names

* add missing eof `fi`

* update logging

* update env setup files

* setup python black

* setup pyright

* remove logging

* update ci

* update actions

* update ci yml

* update regex for test branches

---------

Co-authored-by: WangGLJoseph <[email protected]>
Co-authored-by: Martin Mirchev <[email protected]>
Co-authored-by: autocoderover[bot] <182712390+autocoderover[bot]@users.noreply.github.com>
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 this pull request may close these issues.

None yet

2 participants