Repository: EndlessTrax/pyanchor (language: python)

Issue:
Sourcery refactored dev branch
Branch `dev` refactored by [Sourcery](https://sourcery.ai/github/).

If you're happy with these changes, merge this Pull Request using the *Squash and merge* strategy.

See our documentation [here](https://github.com/sourcery-ai/sourcery/wiki/GitHub-App-Usage).

<details>
<summary>Run Sourcery locally</summary>
<p>
Reduce the feedback loop during development by using the Sourcery editor plugin:
</p>
<ul>
<li><a href="https://sourcery.ai/download/?editor=vscode">VS Code</a></li>
<li><a href="https://sourcery.ai/download/?editor=pycharm">PyCharm</a></li>
</ul>
</details>

<details>
<summary>Review changes via command line</summary>
<p>To manually merge these changes, make sure you're on the <code>dev</code> branch, then run:</p>
<pre>
git fetch origin sourcery/dev
git merge --ff-only FETCH_HEAD
git reset HEAD^
</pre>
</details>


Discussion / hints:

Fix patch:
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 450599a..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-language: python
-python:
-  - "3.6"
-  - "3.7"
-  - "3.8"
-install:
-  - pip install -r requirements-dev.txt
-script:
-  - pytest --cov
-after_success:
-  - bash <(curl -s https://codecov.io/bash)
\ No newline at end of file
diff --git a/pyanchor/cli.py b/pyanchor/cli.py
index 0b3e0b3..c670fae 100644
--- a/pyanchor/cli.py
+++ b/pyanchor/cli.py
@@ -22,7 +22,7 @@ def print_results(links: dict, verbose: bool) -> int:
         if http_code == 200:
             for url in url_list:
                 num_of_successful_links += 1
-                if verbose is True:
+                if verbose:
                     typer.echo(typer.style(f"[ {http_code} ] - {url}", fg="green"))
         elif http_code == 500:
             for url in url_list:
@@ -62,9 +62,9 @@ def main(
     if not url.startswith("http"):
         raise ValueError("Please provide a URL with a valid HTTP scheme")
 
-    if sitemap is True:
+    if sitemap:
         set_of_urls = set()
-        results = dict()
+        results = {}
 
         r = requests.get(url)
         if r.status_code == 200:
@@ -74,7 +74,7 @@ def main(
             for sitemap_link in sitemap_links:
                 set_of_urls.add(sitemap_link.text)
 
-        all_results = list()
+        all_results = []
         for _url in set_of_urls:
             link_results = LinkResults(_url).results
             if len(link_results) > 0:
@@ -84,15 +84,14 @@ def main(
         failed_totals = 0
         for results_dict in all_results:
             _success, _failed = print_results(results_dict, verbose=verbose)
-            success_totals = success_totals + _success
-            failed_totals = failed_totals + _failed
-
-        print_totals(success_totals, failed_totals)
+            success_totals += _success
+            failed_totals += _failed
 
     else:
         results = LinkResults(url).results
         success_totals, failed_totals = print_results(results, verbose=verbose)
-        print_totals(success_totals, failed_totals)
+
+    print_totals(success_totals, failed_totals)
 
 
 if __name__ == "__main__":
diff --git a/pyanchor/link_checker.py b/pyanchor/link_checker.py
index 45d499f..7965523 100644
--- a/pyanchor/link_checker.py
+++ b/pyanchor/link_checker.py
@@ -28,11 +28,7 @@
 
 class AllTags:
     def __init__(self, url: str):
-        if url.endswith("/"):
-            self.base_url = url
-        else:
-            self.base_url = url + "/"
-
+        self.base_url = url if url.endswith("/") else url + "/"
         self.all_atags = self.find_all_atags(self.base_url)
 
     def __str__(self) -> str:
@@ -80,10 +76,10 @@ def check_link_for_http_scheme(self, href: str) -> str:
             return href
 
         elif href.startswith("./"):
-            return self.base_url + re.sub("./", "", href)
+            return self.base_url + href.lstrip("./")
 
         elif href.startswith("../"):
-            return self.base_url + re.sub("../", "", href)
+            return self.base_url + href.lstrip("../")
 
         else:
             return None  # Catches any links starting with hash(#)
@@ -99,7 +95,7 @@ def build_results_dictionary(self) -> dict:
             and the value = a List of URLs that achieved that response code.
         """
 
-        results = dict()
+        results = {}
 
         try:
             for tag in self.all_atags:
@@ -139,14 +135,13 @@ def obsolete_attributes(self, links) -> dict:
 
         OBSOLETE_ATTRS = ("charset", "coords", "name", "rev", "shape")
 
-        return_dict = dict()
+        return_dict = {}
         for link in links:
-            obs_link_attrs = []
-            for attribute in OBSOLETE_ATTRS:
-                if link.get(attribute):
-                    obs_link_attrs.append(attribute)
+            obs_link_attrs = [
+                attribute for attribute in OBSOLETE_ATTRS if link.get(attribute)
+            ]
 
-            if len(obs_link_attrs) > 0:
+            if obs_link_attrs:
                 href = link["href"]
                 if href in return_dict:
                     for _attr in obs_link_attrs:
@@ -173,7 +168,7 @@ def unsafe_attributes(self, links) -> dict:
             Returns a dictionary with the key being the full anchor tag checked, 
             and the value being a `Bool`. False = safe link, True = unsafe.
         """
-        return_dict = dict()
+        return_dict = {}
         for link in links:
             if link.get("target"):
                 if link.get("rel") and "noopener" in link.get("rel"):


Test patch:
diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml
new file mode 100644
index 0000000..b4d3de3
--- /dev/null
+++ b/.github/workflows/run_tests.yml
@@ -0,0 +1,28 @@
+name: Run Tests
+
+on: [push, pull_request]
+
+jobs:
+  testing:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix: 
+        python-version: [3.6, 3.7, 3.8, 3.9]
+        
+    steps:
+    - uses: actions/checkout@v2
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v2
+      with:
+        python-version: ${{ matrix.python-version }}
+
+    - name: Install dependencies
+      run: |
+        python -m pip install --upgrade pip
+        pip install -r requirements-dev.txt
+
+    - name: Run pytest
+      run: pytest --cov
+
+    - name: Coverage report
+      run: bash <(curl -s https://codecov.io/bash)