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

[TT-11627] Migrate failling to golangci-lint/forbidigo, fix issues #6152

Merged
merged 5 commits into from
Mar 15, 2024

Conversation

titpetric
Copy link
Contributor

@titpetric titpetric commented Mar 15, 2024

User description

Tests only changes.

https://tyktech.atlassian.net/browse/TT-11627


Type

enhancement, tests


Description

  • Migrated from faillint to golangci-lint/forbidigo and fixed issues by replacing fmt.Printf with t.Logf in various test files for better logging practices.
  • Added error handling for json.MarshalIndent in apidef/oas/root_test.go.
  • Configured forbidigo linter to forbid fmt.Print* and top-level net/http package functions, enhancing code quality.
  • Removed faillint tool installation and usage from the Makefile, streamlining the linting process.

Changes walkthrough

Relevant files
Tests
linter_test.go
Replace fmt.Printf with t.Logf in OAS Linter Tests             

apidef/oas/linter_test.go

  • Replaced fmt.Printf with t.Logf for error logging in tests.
+1/-2     
root_test.go
Improve Error Handling and Logging in OAS Root Tests         

apidef/oas/root_test.go

  • Added error handling for json.MarshalIndent.
  • Replaced fmt.Println with t.Logf for logging in tests.
  • +4/-2     
    main_test.go
    Use t.Logf for Version Logging in Python Tests                     

    dlpython/main_test.go

    • Replaced fmt.Printf with t.Logf for version logging in tests.
    +1/-2     
    host_checker_test.go
    Replace fmt.Printf with t.Logf in Gateway Host Checker Tests

    gateway/host_checker_test.go

    • Replaced fmt.Printf with t.Logf for logging in tests.
    +2/-3     
    custom_policies_test.go
    Correct Test Metadata in Custom Policies Tests                     

    user/custom_policies_test.go

  • Replaced fmt.Print with TestSessionState_SetCustomPolicies in test
    metadata.
  • +1/-2     
    Configuration changes
    .golangci.yml
    Configure forbidigo Linter and Adjust Issue Handling         

    .golangci.yml

  • Enabled forbidigo linter and configured it to forbid fmt.Print* and
    top-level net/http package functions.
  • Added rules to exclude forbidigo linter in the cli package and
    adjusted issue handling settings.
  • +15/-1   
    Makefile
    Remove faillint Tool from Linting Process                               

    Makefile

    • Removed faillint tool installation and usage.
    +0/-2     

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    @titpetric titpetric requested a review from a team as a code owner March 15, 2024 10:26
    Copy link
    Contributor

    API Changes

    no api changes detected

    Copy link
    Contributor

    PR Description updated to latest commit (16d6713)

    Copy link
    Contributor

    PR Review

    ⏱️ Estimated effort to review [1-5]

    2, because the changes are straightforward, focusing on replacing logging functions and improving error handling in tests. The configuration changes are also clear and well-documented.

    🧪 Relevant tests

    Yes

    🔍 Possible issues

    Possible Bug: In user/custom_policies_test.go, replacing fmt.Print with TestSessionState_SetCustomPolicies in the MetaData map might not be intended. This change alters the test's behavior significantly.

    🔒 Security concerns

    No

    Code feedback:
    relevant fileuser/custom_policies_test.go
    suggestion      

    Verify if replacing fmt.Print with TestSessionState_SetCustomPolicies was intentional. If the goal was to remove fmt.Print, consider using a different approach that doesn't alter the test logic. [important]

    relevant lineMetaData: map[string]interface{}{"policies": []interface{}{TestSessionState_SetCustomPolicies}},

    relevant file.golangci.yml
    suggestion      

    There's a typo in the configuration key for forbidigo. It should be forbidigo instead of fobidigo. Correcting this will ensure the linter is properly configured. [important]

    relevant linefobidigo:

    relevant file.golangci.yml
    suggestion      

    Consider adding fmt.Fprintf and fmt.Fprintln to the list of forbidden functions in the forbidigo configuration to cover all variants of fmt.Print* functions. [medium]

    relevant line- p: ^fmt\.Print.*$


    ✨ Review tool usage guide:

    Overview:
    The review tool scans the PR code changes, and generates a PR review. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
    When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:

    /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
    

    With a configuration file, use the following template:

    [pr_reviewer]
    some_config1=...
    some_config2=...
    
    Utilizing extra instructions

    The review tool can be configured with extra instructions, which can be used to guide the model to a feedback tailored to the needs of your project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify the relevant sub-tool, and the relevant aspects of the PR that you want to emphasize.

    Examples for extra instructions:

    [pr_reviewer] # /review #
    extra_instructions="""
    In the 'possible issues' section, emphasize the following:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    How to enable\disable automation
    • When you first install PR-Agent app, the default mode for the review tool is:
    pr_commands = ["/review", ...]
    

    meaning the review tool will run automatically on every PR, with the default configuration.
    Edit this field to enable/disable the tool, or to change the used configurations

    Auto-labels

    The review tool can auto-generate two specific types of labels for a PR:

    • a possible security issue label, that detects possible security issues (enable_review_labels_security flag)
    • a Review effort [1-5]: x label, where x is the estimated effort to review the PR (enable_review_labels_effort flag)
    Extra sub-tools

    The review tool provides a collection of possible feedbacks about a PR.
    It is recommended to review the possible options, and choose the ones relevant for your use case.
    Some of the feature that are disabled by default are quite useful, and should be considered for enabling. For example:
    require_score_review, require_soc2_ticket, and more.

    Auto-approve PRs

    By invoking:

    /review auto_approve
    

    The tool will automatically approve the PR, and add a comment with the approval.

    To ensure safety, the auto-approval feature is disabled by default. To enable auto-approval, you need to actively set in a pre-defined configuration file the following:

    [pr_reviewer]
    enable_auto_approval = true
    

    (this specific flag cannot be set with a command line argument, only in the configuration file, committed to the repository)

    You can also enable auto-approval only if the PR meets certain requirements, such as that the estimated_review_effort is equal or below a certain threshold, by adjusting the flag:

    [pr_reviewer]
    maximal_review_effort = 5
    
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the review usage page for a comprehensive guide on using this tool.

    Copy link
    Contributor

    github-actions bot commented Mar 15, 2024

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Best practice
    Use t.Errorf for concise test failure reporting.

    Consider using t.Errorf instead of t.Logf followed by t.Fail for more concise and
    idiomatic test failure reporting. This approach allows you to directly indicate the test
    failure with a descriptive message.

    apidef/oas/linter_test.go [103-105]

    -t.Logf("%s\n", err)
    -t.Fail()
    +t.Errorf("%s", err)
     
    Remove unnecessary newline character in log message.

    For consistency and to avoid the extra newline character, consider removing \n from the
    log message since t.Logf already appends a newline at the end of each message.

    dlpython/main_test.go [14]

    -t.Logf("Using Python %s for tests\n", testVersion)
    +t.Logf("Using Python %s for tests", testVersion)
     
    Performance
    Avoid unnecessary string conversion in logging.

    Instead of manually converting ss to a string for logging, consider directly passing the
    byte slice to t.Logf. This avoids unnecessary type conversion and makes the code slightly
    more efficient.

    apidef/oas/root_test.go [88]

    -t.Logf("JSON from filled old:\n%s", string(ss))
    +t.Logf("JSON from filled old:\n%s", ss)
     
    Maintainability
    Combine log messages for clarity and reduced redundancy.

    The log messages within the conditional block could be combined into a single t.Logf call
    to reduce redundancy and improve readability.

    gateway/host_checker_test.go [216-217]

    -t.Logf("Stop loop: %v\n", !ts.Gw.GlobalHostChecker.stopLoop)
    -t.Logf("Am I pooling: %v\n", ts.Gw.GlobalHostChecker.AmIPolling())
    +t.Logf("Stop loop: %v, Am I pooling: %v", !ts.Gw.GlobalHostChecker.stopLoop, ts.Gw.GlobalHostChecker.AmIPolling())
     
    Possible issue
    Correct the typo in the forbidigo configuration key.

    There's a typo in the configuration key for forbidigo. It should be forbidigo instead of
    fobidigo. Correcting this typo will ensure that the linter is properly configured and can
    enforce the specified rules.

    .golangci.yml [91]

    -fobidigo:
    +forbidigo:
     

    ✨ Improve tool usage guide:

    Overview:
    The improve tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on a PR.
    When commenting, to edit configurations related to the improve tool (pr_code_suggestions section), use the following template:

    /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
    

    With a configuration file, use the following template:

    [pr_code_suggestions]
    some_config1=...
    some_config2=...
    
    Enabling\disabling automation

    When you first install the app, the default mode for the improve tool is:

    pr_commands = ["/improve --pr_code_suggestions.summarize=true", ...]
    

    meaning the improve tool will run automatically on every PR, with summarization enabled. Delete this line to disable the tool from running automatically.

    Utilizing extra instructions

    Extra instructions are very important for the improve tool, since they enable to guide the model to suggestions that are more relevant to the specific needs of the project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify relevant aspects that you want the model to focus on.

    Examples for extra instructions:

    [pr_code_suggestions] # /improve #
    extra_instructions="""
    Emphasize the following aspects:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    A note on code suggestions quality
    • While the current AI for code is getting better and better (GPT-4), it's not flawless. Not all the suggestions will be perfect, and a user should not accept all of them automatically.
    • Suggestions are not meant to be simplistic. Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base.
    • Recommended to use the 'extra_instructions' field to guide the model to suggestions that are more relevant to the specific needs of the project, or use the custom suggestions 💎 tool
    • With large PRs, best quality will be obtained by using 'improve --extended' mode.
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the improve usage page for a more comprehensive guide on using this tool.

    Copy link
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    Copy link
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    @titpetric titpetric enabled auto-merge (squash) March 15, 2024 10:52
    Copy link
    Contributor

    💥 CI tests failed 🙈

    git-state

    diff --git a/dlpython/main_test.go b/dlpython/main_test.go
    index 338c4b3..3550025 100644
    --- a/dlpython/main_test.go
    +++ b/dlpython/main_test.go
    @@ -3,8 +3,6 @@ package python
     import (
     	"os"
     	"testing"
    -
    -	log "github.com/sirupsen/logrus"
     )
     
     var testVersion = "3.5"

    Please look at the run or in the Checks tab.

    Copy link

    sonarcloud bot commented Mar 15, 2024

    1 similar comment
    Copy link

    sonarcloud bot commented Mar 15, 2024

    @titpetric titpetric merged commit 3c796bf into master Mar 15, 2024
    31 checks passed
    @titpetric titpetric deleted the test/replace-faillint-with-golangci-lint-forbidigo branch March 15, 2024 11:20
    @titpetric
    Copy link
    Contributor Author

    /release to release-5-lts

    Copy link

    tykbot bot commented Mar 15, 2024

    Working on it! Note that it can take a few minutes.

    tykbot bot pushed a commit that referenced this pull request Mar 15, 2024
    …6152)
    
    Tests only changes.
    
    https://tyktech.atlassian.net/browse/TT-11627
    
    ___
    
    enhancement, tests
    
    ___
    
    - Migrated from `faillint` to `golangci-lint/forbidigo` and fixed issues
    by replacing `fmt.Printf` with `t.Logf` in various test files for better
    logging practices.
    - Added error handling for `json.MarshalIndent` in
    `apidef/oas/root_test.go`.
    - Configured `forbidigo` linter to forbid `fmt.Print*` and top-level
    `net/http` package functions, enhancing code quality.
    - Removed `faillint` tool installation and usage from the Makefile,
    streamlining the linting process.
    
    ___
    
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>linter_test.go</strong><dd><code>Replace fmt.Printf
    with t.Logf in OAS Linter Tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/linter_test.go
    - Replaced `fmt.Printf` with `t.Logf` for error logging in tests.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-b92239afd81e77a829fe7fe8410044dfd4dfda525d17dbf5f8811714a9c986d3">+1/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>root_test.go</strong><dd><code>Improve Error Handling
    and Logging in OAS Root Tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/root_test.go
    <li>Added error handling for <code>json.MarshalIndent</code>.<br> <li>
    Replaced <code>fmt.Println</code> with <code>t.Logf</code> for logging
    in tests.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-4d144465b7fabaf2db8915de1ce3b6ff8c91a93c62d614c38fa38bdae28e23a2">+4/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>main_test.go</strong><dd><code>Use t.Logf for Version
    Logging in Python Tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    dlpython/main_test.go
    - Replaced `fmt.Printf` with `t.Logf` for version logging in tests.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-f8e159e1152ee20ea353fb647d7a7344414006fbd259c4e7073b47c96e8745cb">+1/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>host_checker_test.go</strong><dd><code>Replace
    fmt.Printf with t.Logf in Gateway Host Checker
    Tests</code></dd></summary>
    <hr>
    
    gateway/host_checker_test.go
    - Replaced `fmt.Printf` with `t.Logf` for logging in tests.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-cfc8f5368c14d8fa56d845b1250f465b78c8aa6bfc5b47d0a556d706fa6b8622">+2/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>custom_policies_test.go</strong><dd><code>Correct Test
    Metadata in Custom Policies Tests</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    user/custom_policies_test.go
    <li>Replaced <code>fmt.Print</code> with
    <code>TestSessionState_SetCustomPolicies</code> in test
    <br>metadata.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-c7b1cd92c4c30590d5da9f0d601d6a4957bedded8680da8434c4b76be5a5ed4c">+1/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    </table></td></tr><tr><td><strong>Configuration
    changes</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>.golangci.yml</strong><dd><code>Configure forbidigo
    Linter and Adjust Issue Handling</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    .golangci.yml
    <li>Enabled <code>forbidigo</code> linter and configured it to forbid
    <code>fmt.Print*</code> and <br>top-level <code>net/http</code> package
    functions.<br> <li> Added rules to exclude <code>forbidigo</code> linter
    in the <code>cli</code> package and <br>adjusted issue handling
    settings.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-6179837f7df53a6f05c522b6b7bb566d484d5465d9894fb04910dd08bb40dcc9">+15/-1</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>Makefile</strong><dd><code>Remove faillint Tool from
    Linting Process</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    Makefile
    - Removed `faillint` tool installation and usage.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52">+0/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    </table></td></tr></tr></tbody></table>
    
    ___
    
    > ✨ **PR-Agent usage**:
    >Comment `/help` on the PR to get a list of all available PR-Agent tools
    and their descriptions
    
    ---------
    
    Co-authored-by: Tit Petric <tit@tyk.io>
    
    (cherry picked from commit 3c796bf)
    Copy link

    tykbot bot commented Mar 15, 2024

    @titpetric Succesfully merged PR

    titpetric added a commit that referenced this pull request Mar 15, 2024
    …t/forbidigo, fix issues (#6152) (#6153)
    
    [TT-11627] Migrate failling to golangci-lint/forbidigo, fix issues
    (#6152)
    
    ## **User description**
    Tests only changes.
    
    https://tyktech.atlassian.net/browse/TT-11627
    
    
    ___
    
    ## **Type**
    enhancement, tests
    
    
    ___
    
    ## **Description**
    - Migrated from `faillint` to `golangci-lint/forbidigo` and fixed issues
    by replacing `fmt.Printf` with `t.Logf` in various test files for better
    logging practices.
    - Added error handling for `json.MarshalIndent` in
    `apidef/oas/root_test.go`.
    - Configured `forbidigo` linter to forbid `fmt.Print*` and top-level
    `net/http` package functions, enhancing code quality.
    - Removed `faillint` tool installation and usage from the Makefile,
    streamlining the linting process.
    
    
    ___
    
    
    
    ## **Changes walkthrough**
    <table><thead><tr><th></th><th align="left">Relevant
    
    files</th></tr></thead><tbody><tr><td><strong>Tests</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>linter_test.go</strong><dd><code>Replace fmt.Printf
    with t.Logf in OAS Linter Tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/linter_test.go
    - Replaced `fmt.Printf` with `t.Logf` for error logging in tests.
    
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-b92239afd81e77a829fe7fe8410044dfd4dfda525d17dbf5f8811714a9c986d3">+1/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>root_test.go</strong><dd><code>Improve Error Handling
    and Logging in OAS Root Tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/root_test.go
    <li>Added error handling for <code>json.MarshalIndent</code>.<br> <li>
    Replaced <code>fmt.Println</code> with <code>t.Logf</code> for logging
    in tests.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-4d144465b7fabaf2db8915de1ce3b6ff8c91a93c62d614c38fa38bdae28e23a2">+4/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>main_test.go</strong><dd><code>Use t.Logf for Version
    Logging in Python Tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    dlpython/main_test.go
    - Replaced `fmt.Printf` with `t.Logf` for version logging in tests.
    
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-f8e159e1152ee20ea353fb647d7a7344414006fbd259c4e7073b47c96e8745cb">+1/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>host_checker_test.go</strong><dd><code>Replace
    fmt.Printf with t.Logf in Gateway Host Checker
    Tests</code></dd></summary>
    <hr>
    
    gateway/host_checker_test.go
    - Replaced `fmt.Printf` with `t.Logf` for logging in tests.
    
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-cfc8f5368c14d8fa56d845b1250f465b78c8aa6bfc5b47d0a556d706fa6b8622">+2/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>custom_policies_test.go</strong><dd><code>Correct Test
    Metadata in Custom Policies Tests</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    user/custom_policies_test.go
    <li>Replaced <code>fmt.Print</code> with
    <code>TestSessionState_SetCustomPolicies</code> in test
    <br>metadata.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-c7b1cd92c4c30590d5da9f0d601d6a4957bedded8680da8434c4b76be5a5ed4c">+1/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Configuration
    changes</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>.golangci.yml</strong><dd><code>Configure forbidigo
    Linter and Adjust Issue Handling</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    .golangci.yml
    <li>Enabled <code>forbidigo</code> linter and configured it to forbid
    <code>fmt.Print*</code> and <br>top-level <code>net/http</code> package
    functions.<br> <li> Added rules to exclude <code>forbidigo</code> linter
    in the <code>cli</code> package and <br>adjusted issue handling
    settings.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-6179837f7df53a6f05c522b6b7bb566d484d5465d9894fb04910dd08bb40dcc9">+15/-1</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>Makefile</strong><dd><code>Remove faillint Tool from
    Linting Process</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    Makefile
    - Removed `faillint` tool installation and usage.
    
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52">+0/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr></tr></tbody></table>
    
    ___
    
    > ✨ **PR-Agent usage**:
    >Comment `/help` on the PR to get a list of all available PR-Agent tools
    and their descriptions
    
    ---------
    
    Co-authored-by: Tit Petric <tit@tyk.io>
    
    [TT-11627]:
    https://tyktech.atlassian.net/browse/TT-11627?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
    
    ---------
    
    Co-authored-by: Tit Petric <tit.petric@monotek.net>
    Co-authored-by: Tit Petric <tit@tyk.io>
    @titpetric
    Copy link
    Contributor Author

    /release to release-5.3

    Copy link

    tykbot bot commented Mar 15, 2024

    Working on it! Note that it can take a few minutes.

    Copy link

    tykbot bot commented Mar 15, 2024

    Still working...

    tykbot bot pushed a commit that referenced this pull request Mar 15, 2024
    …6152)
    
    ## **User description**
    Tests only changes.
    
    https://tyktech.atlassian.net/browse/TT-11627
    
    
    ___
    
    ## **Type**
    enhancement, tests
    
    
    ___
    
    ## **Description**
    - Migrated from `faillint` to `golangci-lint/forbidigo` and fixed issues
    by replacing `fmt.Printf` with `t.Logf` in various test files for better
    logging practices.
    - Added error handling for `json.MarshalIndent` in
    `apidef/oas/root_test.go`.
    - Configured `forbidigo` linter to forbid `fmt.Print*` and top-level
    `net/http` package functions, enhancing code quality.
    - Removed `faillint` tool installation and usage from the Makefile,
    streamlining the linting process.
    
    
    ___
    
    
    
    ## **Changes walkthrough**
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>linter_test.go</strong><dd><code>Replace fmt.Printf
    with t.Logf in OAS Linter Tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/linter_test.go
    - Replaced `fmt.Printf` with `t.Logf` for error logging in tests.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-b92239afd81e77a829fe7fe8410044dfd4dfda525d17dbf5f8811714a9c986d3">+1/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>root_test.go</strong><dd><code>Improve Error Handling
    and Logging in OAS Root Tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/root_test.go
    <li>Added error handling for <code>json.MarshalIndent</code>.<br> <li>
    Replaced <code>fmt.Println</code> with <code>t.Logf</code> for logging
    in tests.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-4d144465b7fabaf2db8915de1ce3b6ff8c91a93c62d614c38fa38bdae28e23a2">+4/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>main_test.go</strong><dd><code>Use t.Logf for Version
    Logging in Python Tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    dlpython/main_test.go
    - Replaced `fmt.Printf` with `t.Logf` for version logging in tests.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-f8e159e1152ee20ea353fb647d7a7344414006fbd259c4e7073b47c96e8745cb">+1/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>host_checker_test.go</strong><dd><code>Replace
    fmt.Printf with t.Logf in Gateway Host Checker
    Tests</code></dd></summary>
    <hr>
    
    gateway/host_checker_test.go
    - Replaced `fmt.Printf` with `t.Logf` for logging in tests.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-cfc8f5368c14d8fa56d845b1250f465b78c8aa6bfc5b47d0a556d706fa6b8622">+2/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>custom_policies_test.go</strong><dd><code>Correct Test
    Metadata in Custom Policies Tests</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    user/custom_policies_test.go
    <li>Replaced <code>fmt.Print</code> with
    <code>TestSessionState_SetCustomPolicies</code> in test
    <br>metadata.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-c7b1cd92c4c30590d5da9f0d601d6a4957bedded8680da8434c4b76be5a5ed4c">+1/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Configuration
    changes</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>.golangci.yml</strong><dd><code>Configure forbidigo
    Linter and Adjust Issue Handling</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    .golangci.yml
    <li>Enabled <code>forbidigo</code> linter and configured it to forbid
    <code>fmt.Print*</code> and <br>top-level <code>net/http</code> package
    functions.<br> <li> Added rules to exclude <code>forbidigo</code> linter
    in the <code>cli</code> package and <br>adjusted issue handling
    settings.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-6179837f7df53a6f05c522b6b7bb566d484d5465d9894fb04910dd08bb40dcc9">+15/-1</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>Makefile</strong><dd><code>Remove faillint Tool from
    Linting Process</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    Makefile
    - Removed `faillint` tool installation and usage.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52">+0/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr></tr></tbody></table>
    
    ___
    
    > ✨ **PR-Agent usage**:
    >Comment `/help` on the PR to get a list of all available PR-Agent tools
    and their descriptions
    
    ---------
    
    Co-authored-by: Tit Petric <tit@tyk.io>
    
    (cherry picked from commit 3c796bf)
    buger added a commit that referenced this pull request Mar 15, 2024
    …forbidigo, fix issues (#6152)
    
    [TT-11627] Migrate failling to golangci-lint/forbidigo, fix issues (#6152)
    
    ## **User description**
    Tests only changes.
    
    https://tyktech.atlassian.net/browse/TT-11627
    
    
    ___
    
    ## **Type**
    enhancement, tests
    
    
    ___
    
    ## **Description**
    - Migrated from `faillint` to `golangci-lint/forbidigo` and fixed issues
    by replacing `fmt.Printf` with `t.Logf` in various test files for better
    logging practices.
    - Added error handling for `json.MarshalIndent` in
    `apidef/oas/root_test.go`.
    - Configured `forbidigo` linter to forbid `fmt.Print*` and top-level
    `net/http` package functions, enhancing code quality.
    - Removed `faillint` tool installation and usage from the Makefile,
    streamlining the linting process.
    
    
    ___
    
    
    
    ## **Changes walkthrough**
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>linter_test.go</strong><dd><code>Replace fmt.Printf
    with t.Logf in OAS Linter Tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/linter_test.go
    - Replaced `fmt.Printf` with `t.Logf` for error logging in tests.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-b92239afd81e77a829fe7fe8410044dfd4dfda525d17dbf5f8811714a9c986d3">+1/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>root_test.go</strong><dd><code>Improve Error Handling
    and Logging in OAS Root Tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/root_test.go
    <li>Added error handling for <code>json.MarshalIndent</code>.<br> <li>
    Replaced <code>fmt.Println</code> with <code>t.Logf</code> for logging
    in tests.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-4d144465b7fabaf2db8915de1ce3b6ff8c91a93c62d614c38fa38bdae28e23a2">+4/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>main_test.go</strong><dd><code>Use t.Logf for Version
    Logging in Python Tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    dlpython/main_test.go
    - Replaced `fmt.Printf` with `t.Logf` for version logging in tests.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-f8e159e1152ee20ea353fb647d7a7344414006fbd259c4e7073b47c96e8745cb">+1/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>host_checker_test.go</strong><dd><code>Replace
    fmt.Printf with t.Logf in Gateway Host Checker
    Tests</code></dd></summary>
    <hr>
    
    gateway/host_checker_test.go
    - Replaced `fmt.Printf` with `t.Logf` for logging in tests.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-cfc8f5368c14d8fa56d845b1250f465b78c8aa6bfc5b47d0a556d706fa6b8622">+2/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>custom_policies_test.go</strong><dd><code>Correct Test
    Metadata in Custom Policies Tests</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    user/custom_policies_test.go
    <li>Replaced <code>fmt.Print</code> with
    <code>TestSessionState_SetCustomPolicies</code> in test
    <br>metadata.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-c7b1cd92c4c30590d5da9f0d601d6a4957bedded8680da8434c4b76be5a5ed4c">+1/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Configuration
    changes</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>.golangci.yml</strong><dd><code>Configure forbidigo
    Linter and Adjust Issue Handling</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    .golangci.yml
    <li>Enabled <code>forbidigo</code> linter and configured it to forbid
    <code>fmt.Print*</code> and <br>top-level <code>net/http</code> package
    functions.<br> <li> Added rules to exclude <code>forbidigo</code> linter
    in the <code>cli</code> package and <br>adjusted issue handling
    settings.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-6179837f7df53a6f05c522b6b7bb566d484d5465d9894fb04910dd08bb40dcc9">+15/-1</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>Makefile</strong><dd><code>Remove faillint Tool from
    Linting Process</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    Makefile
    - Removed `faillint` tool installation and usage.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6152/files#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52">+0/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr></tr></tbody></table>
    
    ___
    
    > ✨ **PR-Agent usage**:
    >Comment `/help` on the PR to get a list of all available PR-Agent tools
    and their descriptions
    
    ---------
    
    Co-authored-by: Tit Petric <tit@tyk.io>
    Copy link

    tykbot bot commented Mar 15, 2024

    @titpetric Succesfully merged PR

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

    Successfully merging this pull request may close these issues.

    2 participants