diff --git a/.github/config.yml b/.github/config.yml new file mode 100644 index 0000000..489e39b --- /dev/null +++ b/.github/config.yml @@ -0,0 +1,19 @@ +# Configuration for welcome - https://github.com/behaviorbot/welcome + +# Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome + +# Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome +# Comment to be posted to on PRs from first time contributors in your repository +newPRWelcomeComment: > + Thanks for opening this pull request, a maintainer will get back to you shortly! + In the meantime, please check out the [contributing guidelines](../tree/master/CONTRIBUTING.md). + +# Configuration for sentiment-bot - https://github.com/behaviorbot/sentiment-bot + +# *Required* toxicity threshold between 0 and .99 with the higher numbers being the most toxic +# Anything higher than this threshold will be marked as toxic and commented on +sentimentBotToxicityThreshold: .7 + +# *Required* Comment to reply with +sentimentBotReplyComment: > + Please be respectful of other users. cc/ @rvalitov diff --git a/.github/stale.yml b/.github/stale.yml index 9a6f235..e21c5bf 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -14,4 +14,5 @@ markComment: > recent activity. It will be closed if no further activity occurs. Thank you for your contributions. # Comment to post when closing a stale issue. Set to `false` to disable -closeComment: false +closeComment: > + This issue was automatically closed due to inactivity. diff --git a/.github/workflows/codacy.yml b/.github/workflows/codacy.yml index b91e946..ea6406f 100644 --- a/.github/workflows/codacy.yml +++ b/.github/workflows/codacy.yml @@ -10,10 +10,10 @@ name: Codacy Security Scan on: push: - branches: ["master"] + branches: ["master", "main"] pull_request: - # The branches below must be a subset of the branches above - branches: ["master"] + branches: ["master", "main"] + # Allows you to run this workflow manually from the Actions tab # eslint-disable-next-line yml/no-empty-mapping-value workflow_dispatch: @@ -21,6 +21,11 @@ on: permissions: contents: read +env: + NODE_VERSION: latest + PHP_VERSION: 8.3 + PHPUNIT_VERSION: 11 + jobs: codacy-security-scan: permissions: @@ -28,7 +33,7 @@ jobs: security-events: write # for github/codeql-action/upload-sarif to upload SARIF results actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status name: Codacy Security Scan - runs-on: ubuntu-latest + runs-on: ${{ vars.UBUNTU_VERSION }} steps: # Checkout the repository to the GitHub Actions runner - name: Checkout code @@ -36,7 +41,7 @@ jobs: # Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis - name: Run Codacy Analysis CLI - uses: codacy/codacy-analysis-cli-action@master + uses: codacy/codacy-analysis-cli-action@v4.4.5 with: # Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository # You can also omit the token and run the tools that support default configurations @@ -55,20 +60,57 @@ jobs: uses: github/codeql-action/upload-sarif@v3 with: sarif_file: results.sarif - codacy-analysis-cli: - name: Codacy Analysis CLI + + codacy-coverage-reporter: + name: Codacy Coverage Reporter runs-on: ${{ vars.UBUNTU_VERSION }} - if: github.event_name == 'push' steps: + - name: Setup PHP ${{ env.PHP_VERSION }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ env.PHP_VERSION }} + extensions: mbstring, intl, xdebug, json, sockets + ini-values: max_execution_time=360 + coverage: xdebug + tools: php-cs-fixer, phpunit:${{ env.PHPUNIT_VERSION }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: PHP info + run: php -v + - name: Checkout code - uses: actions/checkout@main + uses: actions/checkout@v4 - - name: Run Codacy Analysis CLI - uses: codacy/codacy-analysis-cli-action@master + - name: Use Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v4.1.0 + with: + node-version: ${{ env.NODE_VERSION }} + cache: "npm" + - name: Validate composer.json and composer.lock + run: composer validate --strict + - name: Install dependencies + run: composer install --prefer-dist --no-progress + - name: Install Node.js dependencies + run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" + + - name: Starting local web server + # bash shell is required for Windows, otherwise the background + # server does not start and work properly + shell: bash + run: npm run start-server & + - name: Wait for server to start up + run: npx wait-on --timeout 15000 http://127.0.0.1:3000 + - name: Server warm up + run: sleep 5 + + - name: Test coverage + run: npm run coverage + - name: Codacy coverage reporter + uses: codacy/codacy-coverage-reporter-action@v1.3.0 with: - verbose: true project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} # or # api-token: ${{ secrets.CODACY_API_TOKEN }} - upload: true - max-allowed-issues: 2147483647 + coverage-reports: coverage/clover.xml + # or a comma-separated list for multiple reports + # coverage-reports: , diff --git a/.github/workflows/devskim.yml b/.github/workflows/devskim.yml index b0f542f..3da6bc9 100644 --- a/.github/workflows/devskim.yml +++ b/.github/workflows/devskim.yml @@ -7,9 +7,10 @@ name: DevSkim on: push: - branches: ["master"] + branches: ["master", "main"] pull_request: - branches: ["master"] + branches: ["master", "main"] + # Allows you to run this workflow manually from the Actions tab # eslint-disable-next-line yml/no-empty-mapping-value workflow_dispatch: @@ -17,7 +18,7 @@ on: jobs: lint: name: DevSkim - runs-on: ubuntu-latest + runs-on: ${{ vars.UBUNTU_VERSION }} permissions: actions: read contents: read diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 537f20b..5437d24 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -6,11 +6,12 @@ name: SonarCloud analysis on: push: - branches: ["master"] + branches: ["master", "main"] pull_request: - branches: ["master"] + branches: ["master", "main"] types: [opened, synchronize, reopened] + # Allows you to run this workflow manually from the Actions tab # eslint-disable-next-line yml/no-empty-mapping-value workflow_dispatch: @@ -19,6 +20,8 @@ permissions: env: NODE_VERSION: latest + PHP_VERSION: 8.3 + PHPUNIT_VERSION: 11 jobs: sonarqube: @@ -26,21 +29,53 @@ jobs: runs-on: ${{ vars.UBUNTU_VERSION }} steps: + - name: Setup PHP ${{ env.PHP_VERSION }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ env.PHP_VERSION }} + extensions: mbstring, intl, xdebug, json, sockets + ini-values: max_execution_time=360 + coverage: xdebug + tools: php-cs-fixer, phpunit:${{ env.PHPUNIT_VERSION }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: PHP info + run: php -v + - name: Checkout uses: actions/checkout@v4 with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + # Disabling shallow clones is recommended for improving the relevancy of reporting + fetch-depth: 0 + - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@master + uses: actions/setup-node@v4.1.0 with: node-version: ${{ env.NODE_VERSION }} cache: "npm" + - name: Install dependencies + run: composer install --prefer-dist --no-progress - name: Install Node.js dependencies run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" + + - name: Starting local web server + # bash shell is required for Windows, otherwise the background + # server does not start and work properly + shell: bash + run: npm run start-server & + - name: Wait for server to start up + run: npx wait-on --timeout 15000 http://127.0.0.1:3000 + - name: Server warm up + run: sleep 5 + - name: Test coverage run: npm run coverage + - name: SonarQube Scan - uses: SonarSource/sonarqube-scan-action@v4 + uses: SonarSource/sonarqube-scan-action@v4.2.1 + with: + args: > + -Dsonar.verbose=true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3e6f464..1f9b202 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,9 +2,9 @@ name: Tests on: push: - branches: ["master"] + branches: ["master", "main"] pull_request: - branches: ["master"] + branches: ["master", "main"] permissions: contents: read @@ -64,6 +64,8 @@ jobs: restore-keys: | ${{ runner.os }}-php- + - name: Validate composer.json and composer.lock + run: composer validate --strict - name: Install dependencies run: composer install --prefer-dist --no-progress @@ -91,14 +93,3 @@ jobs: - if: matrix.operating-system != 'windows-latest' name: Run full test suite run: npm run test - - - if: github.actor != 'dependabot[bot]' - name: Codacy coverage reporter - uses: codacy/codacy-coverage-reporter-action@master - with: - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} - # or - # api-token: ${{ secrets.CODACY_API_TOKEN }} - coverage-reports: ./coverage/clover.xml - # or a comma-separated list for multiple reports - # coverage-reports: , diff --git a/.gitignore b/.gitignore index 9f7bc1b..91a3af2 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,3 @@ node_modules/ *.phar *.cache coverage - diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..1a21339 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,91 @@ +# Contributing to Backlink Checker PHP + +Thank you for considering contributing to this project! +To contribute, please follow these guidelines. + +## 1. Fork the Repository and Create Your Branch + +1. Fork the repository. +2. Create a new branch from `master` for your changes. + +## 2. Adhere to Existing Style Conventions + +Ensure your code adheres to the existing style conventions used in the project. +You can use the following command to check the style conventions: + +```bash +npm run style +``` + +If you see any errors or warnings, please fix them before opening a pull request. + +You can use the following command to fix the Markdown style issues: + +```bash +npm run markdown:fix +``` + +To fix other style issues, you can use the following command: + +```bash +npm run prettier:fix +``` + +If you modify the dependencies in `package.json` or `composer.json` or modify these files manually, +please keep the file sorted: + +```bash +npm run sort +``` + +## 3. Run Tests to Ensure Changes Do Not Break Functionality + +First run the tests for static PHP code analysis: + +```bash +npm run php +``` + +If you see any errors or warnings, please fix them before opening a pull request. +Some errors or warnings can be fixed automatically using the following command: + +```bash +npm run phpcs-fixer:fix +``` + +Then run the PHPUnit tests for the PHP code. First start the server: + +```bash +npm run start-server +``` + +Then run the tests. +Be sure to keep the server running while running the tests. +You can run the tests using the following command in a new terminal: + +```bash +npm run test +``` + +This command will run all the tests, including the static analysis checks. + +## 4. Add New Tests for Your Changes if Applicable + +* Add new tests for your changes if applicable. +* Ensure the tests cover all the possible scenarios and edge cases. +* The tests should be added to the `tests` directory. +* Sample data for the tests should be added to the `tests/data` directory. + +## 5. Open a Pull Request with a Clear Description + +Open a pull request with a clear description of your changes and the problem they solve. +If your pull request fixes an issue, please reference the issue in the pull request description. + +## 6. Update the Documentation + +If you add new features or modify existing features, please update the `README.md` file. + +## 7. Resources + +* [Using Pull Requests](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) +* [GitHub Flow](https://docs.github.com/en/get-started/using-github/github-flow) diff --git a/README.md b/README.md index b313f30..e9182c5 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,16 @@ ![Platform icon](https://img.shields.io/badge/Platform-Windows%2C%20Linux%2C%20Mac-blue) ![Packagist Downloads](https://img.shields.io/packagist/dt/rvalitov/backlink-checker-php) ![Packagist Stars](https://img.shields.io/packagist/stars/rvalitov/backlink-checker-php) -[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/328e8eae9a494098b8a8ee66d602f781)](https://app.codacy.com/gh/rvalitov/backlink-checker-php/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage) -[![Codacy Badge](https://app.codacy.com/project/badge/Grade/328e8eae9a494098b8a8ee66d602f781)](https://app.codacy.com/gh/rvalitov/backlink-checker-php/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) -[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=rvalitov_backlink-checker-php&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php) -[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=rvalitov_backlink-checker-php&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php) -[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=rvalitov_backlink-checker-php&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php) -[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=rvalitov_backlink-checker-php&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php) -[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=rvalitov_backlink-checker-php&metric=bugs)](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php) -[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=rvalitov_backlink-checker-php&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php) -[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=rvalitov_backlink-checker-php&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php) -[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=rvalitov_backlink-checker-php&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php) +[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/328e8eae9a494098b8a8ee66d602f781)](https://app.codacy.com/gh/rvalitov/backlink-checker-php/dashboard?utm_source=gh\&utm_medium=referral\&utm_content=\&utm_campaign=Badge_coverage) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/328e8eae9a494098b8a8ee66d602f781)](https://app.codacy.com/gh/rvalitov/backlink-checker-php/dashboard?utm_source=gh\&utm_medium=referral\&utm_content=\&utm_campaign=Badge_grade) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=rvalitov_backlink-checker-php\&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php) +[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=rvalitov_backlink-checker-php\&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php) +[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=rvalitov_backlink-checker-php\&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php) +[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=rvalitov_backlink-checker-php\&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php) +[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=rvalitov_backlink-checker-php\&metric=bugs)](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php) +[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=rvalitov_backlink-checker-php\&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php) +[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=rvalitov_backlink-checker-php\&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php) +[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=rvalitov_backlink-checker-php\&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=rvalitov_backlink-checker-php) [![Tests](https://github.com/rvalitov/backlink-checker-php/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/rvalitov/backlink-checker-php/actions/workflows/tests.yml) ![GitHub License](https://img.shields.io/github/license/rvalitov/backlink-checker-php?color=blue) @@ -25,17 +25,17 @@ our tool focuses exclusively on verifying backlinks from a list you already have You might get this list of backlinks through: -- **Purchasing backlinks**: Receiving a list of donor web pages from the seller or backlinks market. -- **Creating backlinks yourself**: Posting on forums, third-party websites, or other platforms. -- **SEO service providers**: your SEO expert or company shares a reports with backlinks as one of the SEO strategies. +* **Purchasing backlinks**: Receiving a list of donor web pages from the seller or backlinks market. +* **Creating backlinks yourself**: Posting on forums, third-party websites, or other platforms. +* **SEO service providers**: your SEO expert or company shares a reports with backlinks as one of the SEO strategies. Once you have a list of donor web pages, it's crucial to confirm that the backlinks are present and functional. Moreover, ongoing validation is necessary to ensure the backlinks remain active and haven’t been removed over time. This package simplifies backlink checking and verification by: -- Verifying the presence of fixed backlinks, such as `https://example.com`. -- Supporting powerful search patterns, like `*.example.com`, using +* Verifying the presence of fixed backlinks, such as `https://example.com`. +* Supporting powerful search patterns, like `*.example.com`, using [regular expressions](https://en.wikipedia.org/wiki/Regular_expression) defined by you. With this package, monitoring and maintaining your backlinks becomes efficient and hassle-free. @@ -46,14 +46,14 @@ With this package, monitoring and maintaining your backlinks becomes efficient a Pros: -- **Fast**: Simple mode is faster. -- **Low resource consumption**: Simple mode uses fewer resources. -- **Minimal dependencies**: Simple mode requires fewer dependencies. -- **Shared hosting**: Simple mode works on shared hosting. +* **Fast**: Simple mode is faster. +* **Low resource consumption**: Simple mode uses fewer resources. +* **Minimal dependencies**: Simple mode requires fewer dependencies. +* **Shared hosting**: Simple mode works on shared hosting. Cons: -- **No JavaScript**: Simple mode does not support JavaScript, +* **No JavaScript**: Simple mode does not support JavaScript, so it works only for simple or static HTML, for example, generated by Joomla, WordPress or Drupal. It will not find backlinks on websites that require JavaScript-enabled browser, for example, websites made with Laravel, Yii, React, etc. @@ -67,13 +67,13 @@ but it uses more resources on the server and requires a little bit more time to Pros: -- **Universal**: Chromium mode supports JavaScript, so it can parse any website. +* **Universal**: Chromium mode supports JavaScript, so it can parse any website. Cons: -- **Slower**: Chromium mode is slower. -- **Higher resource consumption**: Chromium mode uses more resources. -- **Advanced hosting plan**: requires a VPS or dedicated server, does not work on shared hosting. +* **Slower**: Chromium mode is slower. +* **Higher resource consumption**: Chromium mode uses more resources. +* **Advanced hosting plan**: requires a VPS or dedicated server, does not work on shared hosting. ## How to Install @@ -86,8 +86,8 @@ Run the following command: php composer require rvalitov/backlink-checker-php ``` -- Versions starting from 3.0.0 support PHP 8.0 and later. -- If you need to use an earlier version of PHP, please use the 1.x.x or 2.x.x releases. +* Versions starting from 3.0.0 support PHP 8.0 and later. +* If you need to use an earlier version of PHP, please use the 1.x.x or 2.x.x releases. ### Step 2. Install the Chromium @@ -107,7 +107,7 @@ If it's not installed, install it using the official manual. Then run the following command to install the Chromium: ```bash -npm install +npm install https://github.com/zoonru/rialto ``` ### Step 3. Use Autoload @@ -161,14 +161,14 @@ try { The function `getBacklinks` has the following additional options: -- `$scanBacklinks` - if set to `true`, +* `$scanBacklinks` - if set to `true`, then it scans for the backlinks (the text of the `href` attribute of [``](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) tag); otherwise scanning is not performed. -- `$scanHotlinks` - if set to `true`, then it scans for the [hotlink](https://simple.wikipedia.org/wiki/Hotlinking) (the +* `$scanHotlinks` - if set to `true`, then it scans for the [hotlink](https://simple.wikipedia.org/wiki/Hotlinking) (the text of the `src` attribute of [``](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img) tag); otherwise scanning is not performed. -- `$makeScreenshot` - if set to `true`, then we also take a screenshot of the viewport; otherwise screenshot is not +* `$makeScreenshot` - if set to `true`, then we also take a screenshot of the viewport; otherwise screenshot is not made. This option makes sense only for Chromium mode (default viewport size is `800 x 600` px, image format: `JPEG`, image quality: `90`, image encoding: `binary`); for simple mode this option is ignored. @@ -193,20 +193,20 @@ if ($response->isSuccess()) { The function `$result->getBacklinks()` returns an array of objects that describe the backlink. Each object supports the following functions: -- `getBacklink` returns `string`, a backlink - an exact URL that matches the target domain; -- `getTag` returns `string`, the tag that is used for the backlink, can be `a` or `img`; -- `getTarget` returns `string`, contents of +* `getBacklink` returns `string`, a backlink - an exact URL that matches the target domain; +* `getTag` returns `string`, the tag that is used for the backlink, can be `a` or `img`; +* `getTarget` returns `string`, contents of [`target`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/A#attr-target) attribute of the `href`; -- `getNoFollow` returns `true` if the backlink has [`nofollow`](https://en.wikipedia.org/wiki/Nofollow) attribute; -- `getAnchor` returns `string` - anchor of the link, for example, inner text of `` tag. This text is returned in a +* `getNoFollow` returns `true` if the backlink has [`nofollow`](https://en.wikipedia.org/wiki/Nofollow) attribute; +* `getAnchor` returns `string` - anchor of the link, for example, inner text of `` tag. This text is returned in a plain text format, all HTML tags are stripped. The `$response` object supports the following functions: -- `getUrl` returns `string`, the URL of that was analyzed -- `getStatusCode` returns `int`, the [HTTP status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes), or `0` +* `getUrl` returns `string`, the URL of that was analyzed +* `getStatusCode` returns `int`, the [HTTP status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes), or `0` or `-1` if there was a network error. -- `getScreenshot` returns `string`, the screenshot in binary format. If the screenshot was not taken or is not +* `getScreenshot` returns `string`, the screenshot in binary format. If the screenshot was not taken or is not available, then the string is empty. If you want to display this screenshot as an image on a web page, then you should first save it to disk and use a link to it, or encode it into [base64](https://en.wikipedia.org/wiki/Data_URI_scheme) and insert into the web page directly. In this case, you can use a function like: @@ -228,5 +228,5 @@ Tests are in `tests` folder. PHP 8.0.7+ required with the following extensions: -- [`json`](https://www.php.net/manual/en/json.installation.php) -- [`sockets`](https://www.php.net/manual/en/sockets.installation.php) +* [`json`](https://www.php.net/manual/en/json.installation.php) +* [`sockets`](https://www.php.net/manual/en/sockets.installation.php) diff --git a/composer.json b/composer.json index 72c6bff..280ca2e 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "phpmd": "phpmd src/ text phpmd.xml", "phpstan": "phpstan analyse --level max src tests", "psalm": "psalm --show-info=true", - "test": "phpunit --coverage-clover ./coverage/clover.xml --coverage-html ./coverage/html --coverage-xml ./coverage/xml --coverage-text" + "test": "phpunit --coverage-clover ./coverage/clover.xml --coverage-html ./coverage/html --coverage-xml ./coverage/xml --coverage-text --log-junit ./coverage/execution.xml" }, "authors": [ { diff --git a/package.json b/package.json index 32c0b70..8175ee7 100644 --- a/package.json +++ b/package.json @@ -5,13 +5,14 @@ "license": "GPL-3.0", "author": "Ramil Valitov ", "scripts": { - "coverage": "php ./vendor/bin/phpunit --coverage-clover ./coverage/clover.xml --coverage-html ./coverage/html --coverage-xml ./coverage/xml --coverage-text", + "coverage": "php ./vendor/bin/phpunit --coverage-clover ./coverage/clover.xml --coverage-html ./coverage/html --coverage-xml ./coverage/xml --coverage-text --log-junit ./coverage/execution.xml", "json": "jsonlint -q ./*.json", "lint": "eslint .", "markdown": "remark . --frail", "markdown:fix": "remark . --frail --output", "markdownlint": "markdownlint --config .markdownlint.json \"*.md\"", "package": "npx npm-package-json-lint .", + "php": "npm run phpcs && npm run phpmd && npm run phpcs-fixer", "phpcs": "php ./vendor/bin/phpcs --standard=PSR2 src/", "phpcs-fixer": "php ./vendor/bin/php-cs-fixer --verbose check", "phpcs-fixer:fix": "php ./vendor/bin/php-cs-fixer fix", @@ -22,8 +23,10 @@ "psalm": "php ./vendor/bin/psalm --show-info=true", "sort": "sort-package-json ./package.json ./composer.json", "start-server": "npx serve -n tests/data", - "test": "npm run markdown && npm run markdownlint && npm run json && npm run package && npm run lint && npm run prettier && npm run phpcs && npm run phpmd && npm run phpcs-fixer && npm run psalm && npm run coverage", - "test:small": "npm run markdown && npm run markdownlint && npm run json && npm run package && npm run lint && npm run phpcs && npm run phpmd && npm run phpcs-fixer && npm run psalm && npm run coverage" + "style": "npm run style:windows && npm run prettier", + "style:windows": "npm run markdown && npm run markdownlint && npm run json && npm run package && npm run lint", + "test": "npm run style && npm run php && npm run coverage", + "test:small": "npm run style:windows && npm run php && npm run coverage" }, "remarkConfig": { "plugins": [ diff --git a/sonar-project.properties b/sonar-project.properties index 3b1912c..0ff14a3 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,7 @@ sonar.projectKey=rvalitov_backlink-checker-php sonar.organization=rvalitov +sonar.projectBaseDir=. # Define separate root directories for sources and tests sonar.sources = src/ sonar.tests = tests/ @@ -8,3 +9,4 @@ sonar.tests = tests/ sonar.exclusions = tests/data/* sonar.php.coverage.reportPaths=coverage/clover.xml +sonar.php.tests.reportPath=coverage/execution.xml