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

[FEATURE REQUEST] How to use prospector on a string #653

Open
sadrasabouri opened this issue Feb 6, 2024 · 0 comments
Open

[FEATURE REQUEST] How to use prospector on a string #653

sadrasabouri opened this issue Feb 6, 2024 · 0 comments

Comments

@sadrasabouri
Copy link

Is your feature request related to a problem? Please describe.
I was looking for a software analysis package on a string given by function; then I found your great package. I realized that I can save the function into a .py file and run prospector on that directory, but it seems inefficient. I checked on the code and found out that getting reports for tools are delegated to a Manager object of that class that gets path to the file on system.

Describe the solution you'd like
I was looking for some API like the code below.

from prospector import Analysis
function_str = """def bubbleSort(arr):
    n = len(arr)
    swapped = False
    for i in range(n-1):
        for j in range(0, n-i-1):
            if arr[j] > arr[j + 1]:
                swapped = True
                arr[j], arr[j + 1] = arr[j + 1], arr[j]
         
        if not swapped:
            return
"""
data = Analysis(function_str, output="json")
#{
#  "summary": {
#    "started": "2024-02-06 10:34:54.470164",
#    "libraries": [],
#    "strictness": "high",
#    "profiles": "default, strictness_high, strictness_veryhigh, no_doc_warnings, no_test_warnings, no_member_warnings",
#    "tools": [
#      "bandit",
#      "dodgy",
#      "mccabe",
#      "mypy",
#      "profile-validator",
#      "pycodestyle",
#      "pyflakes",
#      "pylint"
#    ],
#    "message_count": 7,

Describe alternatives you've considered
I have tried saving Python file and running prospector and it. Not only it's not an optimal solution when you are dealing with thousands of code functions, but also there was an issue using subprocess.check_output returning nonzero code that I will open a separate issue thread for that when I am sure the issue if not from my side.

Additional context
I read the documentation once and skimed through the codebase. I believe there should be an easy solution for it. Even a simple hint would solve my problem.

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

No branches or pull requests

1 participant