We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
cfn-lint shows `W1020 Fn::Sub isn't needed` on Serverless LayerVersion property LayerName when a Variable is actually present
*cfn-lint version: 0.20.1*

cfn-lint shows `W1020 Fn::Sub isn't needed` on Serverless LayerVersion property LayerName when a Variable is actually present in the layerName String of the intrinsic function Sub

Please provide as much information as possible:

sample resource: 
```yaml
APICommonCodeLayer:
    Type: 'AWS::Serverless::LayerVersion'
    Properties:
      Description: API common libraries
      LayerName: 
        Fn::Sub: 'api-common-code-layer-${Environment}'
      ContentUri: api/common
      CompatibleRuntimes:
        - nodejs8.10
      RetentionPolicy: Retain
```
Where Environment is a Paramater with the following definition:

```yaml
Environment:
    AllowedValues:
      - Dev
      - Qa
      - Staging
      - Mirror
      - Prod
    ConstraintDescription: You must specify a valid EnvironmentValue
    Default: Dev
    Description: Environment for to Deploy to
    Type: String
```
This only seems to affect LayerVersions as other resources proceed to not return the warning when using Fn::Sub in their names, even other AWS::Serverless resources.

Sample Template:
```yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: SampleTemplate
Parameters:
  Environment:
    Type: String
    AllowedValues:
      - Dev
      - Qa
      - Staging
      - Mirror
      - Prod
    ConstraintDescription: You must specify a valid EnvironmentValue
    Default: Dev
    Description: Environment for to Deploy to
Resources:
  APICommonCodeLayer:
    Type: 'AWS::Serverless::LayerVersion'
    Properties:
      Description: API common libraries
      LayerName: 
        Fn::Sub: 'api-common-code-layer-${Environment}'
      ContentUri: api/common
      CompatibleRuntimes:
        - nodejs8.10
      RetentionPolicy: Retain
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setup.py`
Content:
```
1 """
2   Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 
4   Permission is hereby granted, free of charge, to any person obtaining a copy of this
5   software and associated documentation files (the "Software"), to deal in the Software
6   without restriction, including without limitation the rights to use, copy, modify,
7   merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
8   permit persons to whom the Software is furnished to do so.
9 
10   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
11   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
12   PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
13   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
14   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
15   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 """
17 import codecs
18 import re
19 from setuptools import find_packages
20 from setuptools import setup
21 
22 
23 def get_version(filename):
24     with codecs.open(filename, 'r', 'utf-8') as fp:
25         contents = fp.read()
26     return re.search(r"__version__ = ['\"]([^'\"]+)['\"]", contents).group(1)
27 
28 
29 version = get_version('src/cfnlint/version.py')
30 
31 
32 with open('README.md') as f:
33     readme = f.read()
34 
35 setup(
36     name='cfn-lint',
37     version=version,
38     description=('checks cloudformation for practices and behaviour \
39         that could potentially be improved'),
40     long_description=readme,
41     long_description_content_type="text/markdown",
42     keywords='aws, lint',
43     author='kddejong',
44     author_email='kddejong@amazon.com',
45     url='https://github.com/aws-cloudformation/cfn-python-lint',
46     package_dir={'': 'src'},
47     package_data={'cfnlint': [
48         'data/CloudSpecs/*.json',
49         'data/AdditionalSpecs/*.json',
50         'data/Serverless/*.json',
51         'data/ExtendedSpecs/all/*.json',
52         'data/ExtendedSpecs/ap-northeast-1/*.json',
53         'data/ExtendedSpecs/ap-northeast-2/*.json',
54         'data/ExtendedSpecs/ap-northeast-3/*.json',
55         'data/ExtendedSpecs/ap-south-1/*.json',
56         'data/ExtendedSpecs/ap-southeast-1/*.json',
57         'data/ExtendedSpecs/ap-southeast-2/*.json',
58         'data/ExtendedSpecs/ca-central-1/*.json',
59         'data/ExtendedSpecs/eu-central-1/*.json',
60         'data/ExtendedSpecs/eu-north-1/*.json',
61         'data/ExtendedSpecs/eu-west-1/*.json',
62         'data/ExtendedSpecs/eu-west-2/*.json',
63         'data/ExtendedSpecs/eu-west-3/*.json',
64         'data/ExtendedSpecs/sa-east-1/*.json',
65         'data/ExtendedSpecs/us-east-1/*.json',
66         'data/ExtendedSpecs/us-east-2/*.json',
67         'data/ExtendedSpecs/us-gov-east-1/*.json',
68         'data/ExtendedSpecs/us-gov-west-1/*.json',
69         'data/ExtendedSpecs/us-west-1/*.json',
70         'data/ExtendedSpecs/us-west-2/*.json',
71         'data/CfnLintCli/config/schema.json'
72     ]},
73     packages=find_packages('src'),
74     zip_safe=False,
75     install_requires=[
76         'pyyaml',
77         'six~=1.11',
78         'requests>=2.15.0',
79         'aws-sam-translator>=1.10.0',
80         'jsonpatch',
81         'jsonschema~=2.6',
82         'pathlib2>=2.3.0;python_version<"3.4"'
83     ],
84     python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
85     entry_points={
86         'console_scripts': [
87             'cfn-lint = cfnlint.__main__:main'
88         ]
89     },
90     license='MIT no attribution',
91     test_suite="unittest",
92     classifiers=[
93         'Development Status :: 5 - Production/Stable',
94         'Intended Audience :: Developers',
95         'License :: OSI Approved :: MIT License',
96         'Natural Language :: English',
97         'Operating System :: OS Independent',
98         'Programming Language :: Python :: 2',
99         'Programming Language :: Python :: 2.7',
100         'Programming Language :: Python :: 3',
101         'Programming Language :: Python :: 3.4',
102         'Programming Language :: Python :: 3.5',
103         'Programming Language :: Python :: 3.6',
104         'Programming Language :: Python :: 3.7',
105     ],
106 )
107
```

Path: `src/cfnlint/rules/functions/SubUnneeded.py`
Content:
```
1 """
2   Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 
4   Permission is hereby granted, free of charge, to any person obtaining a copy of this
5   software and associated documentation files (the "Software"), to deal in the Software
6   without restriction, including without limitation the rights to use, copy, modify,
7   merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
8   permit persons to whom the Software is furnished to do so.
9 
10   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
11   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
12   PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
13   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
14   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
15   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 """
17 import six
18 from cfnlint import CloudFormationLintRule
19 from cfnlint import RuleMatch
20 
21 
22 class SubUnneeded(CloudFormationLintRule):
23     """Check if Sub is using a variable"""
24     id = 'W1020'
25     shortdesc = 'Sub isn\'t needed if it doesn\'t have a variable defined'
26     description = 'Checks sub strings to see if a variable is defined.'
27     source_url = 'https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html'
28     tags = ['functions', 'sub']
29 
30     def _test_string(self, cfn, sub_string, tree):
31         """Test if a string has appropriate parameters"""
32 
33         matches = []
34         string_params = cfn.get_sub_parameters(sub_string)
35 
36         if not string_params:
37             message = 'Fn::Sub isn\'t needed because there are no variables at {0}'
38             matches.append(RuleMatch(
39                 tree, message.format('/'.join(map(str, tree)))))
40 
41         return matches
42 
43     def match(self, cfn):
44         """Check CloudFormation Join"""
45 
46         matches = []
47 
48         sub_objs = cfn.search_deep_keys('Fn::Sub')
49 
50         for sub_obj in sub_objs:
51             sub_value_obj = sub_obj[-1]
52             tree = sub_obj[:-1]
53             if isinstance(sub_value_obj, six.string_types):
54                 matches.extend(self._test_string(cfn, sub_value_obj, tree))
55             elif isinstance(sub_value_obj, list):
56                 if len(sub_value_obj) == 2:
57                     sub_string = sub_value_obj[0]
58                     matches.extend(self._test_string(cfn, sub_string, tree + [0]))
59 
60         return matches
61
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -75,7 +75,7 @@
     install_requires=[
         'pyyaml',
         'six~=1.11',
-        'requests>=2.15.0',
+        'requests>=2.15.0,<=2.21.0',
         'aws-sam-translator>=1.10.0',
         'jsonpatch',
         'jsonschema~=2.6',
diff --git a/src/cfnlint/rules/functions/SubUnneeded.py b/src/cfnlint/rules/functions/SubUnneeded.py
--- a/src/cfnlint/rules/functions/SubUnneeded.py
+++ b/src/cfnlint/rules/functions/SubUnneeded.py
@@ -45,7 +45,7 @@
 
         matches = []
 
-        sub_objs = cfn.search_deep_keys('Fn::Sub')
+        sub_objs = cfn.transform_pre.get('Fn::Sub')
 
         for sub_obj in sub_objs:
             sub_value_obj = sub_obj[-1]

{"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -75,7 +75,7 @@\n     install_requires=[\n         'pyyaml',\n         'six~=1.11',\n-        'requests>=2.15.0',\n+        'requests>=2.15.0,<=2.21.0',\n         'aws-sam-translator>=1.10.0',\n         'jsonpatch',\n         'jsonschema~=2.6',\ndiff --git a/src/cfnlint/rules/functions/SubUnneeded.py b/src/cfnlint/rules/functions/SubUnneeded.py\n--- a/src/cfnlint/rules/functions/SubUnneeded.py\n+++ b/src/cfnlint/rules/functions/SubUnneeded.py\n@@ -45,7 +45,7 @@\n \n         matches = []\n \n-        sub_objs = cfn.search_deep_keys('Fn::Sub')\n+        sub_objs = cfn.transform_pre.get('Fn::Sub')\n \n         for sub_obj in sub_objs:\n             sub_value_obj = sub_obj[-1]\n", "issue": "cfn-lint shows `W1020 Fn::Sub isn't needed` on Serverless LayerVersion property LayerName when a Variable is actually present\n*cfn-lint version: 0.20.1*\r\n\r\ncfn-lint shows `W1020 Fn::Sub isn't needed` on Serverless LayerVersion property LayerName when a Variable is actually present in the layerName String of the intrinsic function Sub\r\n\r\nPlease provide as much information as possible:\r\n\r\nsample resource: \r\n```yaml\r\nAPICommonCodeLayer:\r\n    Type: 'AWS::Serverless::LayerVersion'\r\n    Properties:\r\n      Description: API common libraries\r\n      LayerName: \r\n        Fn::Sub: 'api-common-code-layer-${Environment}'\r\n      ContentUri: api/common\r\n      CompatibleRuntimes:\r\n        - nodejs8.10\r\n      RetentionPolicy: Retain\r\n```\r\nWhere Environment is a Paramater with the following definition:\r\n\r\n```yaml\r\nEnvironment:\r\n    AllowedValues:\r\n      - Dev\r\n      - Qa\r\n      - Staging\r\n      - Mirror\r\n      - Prod\r\n    ConstraintDescription: You must specify a valid EnvironmentValue\r\n    Default: Dev\r\n    Description: Environment for to Deploy to\r\n    Type: String\r\n```\r\nThis only seems to affect LayerVersions as other resources proceed to not return the warning when using Fn::Sub in their names, even other AWS::Serverless resources.\r\n\r\nSample Template:\r\n```yaml\r\nAWSTemplateFormatVersion: '2010-09-09'\r\nTransform: 'AWS::Serverless-2016-10-31'\r\nDescription: SampleTemplate\r\nParameters:\r\n  Environment:\r\n    Type: String\r\n    AllowedValues:\r\n      - Dev\r\n      - Qa\r\n      - Staging\r\n      - Mirror\r\n      - Prod\r\n    ConstraintDescription: You must specify a valid EnvironmentValue\r\n    Default: Dev\r\n    Description: Environment for to Deploy to\r\nResources:\r\n  APICommonCodeLayer:\r\n    Type: 'AWS::Serverless::LayerVersion'\r\n    Properties:\r\n      Description: API common libraries\r\n      LayerName: \r\n        Fn::Sub: 'api-common-code-layer-${Environment}'\r\n      ContentUri: api/common\r\n      CompatibleRuntimes:\r\n        - nodejs8.10\r\n      RetentionPolicy: Retain\r\n```\r\n\n", "before_files": [{"content": "\"\"\"\n  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this\n  software and associated documentation files (the \"Software\"), to deal in the Software\n  without restriction, including without limitation the rights to use, copy, modify,\n  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n  permit persons to whom the Software is furnished to do so.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\"\"\"\nimport codecs\nimport re\nfrom setuptools import find_packages\nfrom setuptools import setup\n\n\ndef get_version(filename):\n    with codecs.open(filename, 'r', 'utf-8') as fp:\n        contents = fp.read()\n    return re.search(r\"__version__ = ['\\\"]([^'\\\"]+)['\\\"]\", contents).group(1)\n\n\nversion = get_version('src/cfnlint/version.py')\n\n\nwith open('README.md') as f:\n    readme = f.read()\n\nsetup(\n    name='cfn-lint',\n    version=version,\n    description=('checks cloudformation for practices and behaviour \\\n        that could potentially be improved'),\n    long_description=readme,\n    long_description_content_type=\"text/markdown\",\n    keywords='aws, lint',\n    author='kddejong',\n    author_email='kddejong@amazon.com',\n    url='https://github.com/aws-cloudformation/cfn-python-lint',\n    package_dir={'': 'src'},\n    package_data={'cfnlint': [\n        'data/CloudSpecs/*.json',\n        'data/AdditionalSpecs/*.json',\n        'data/Serverless/*.json',\n        'data/ExtendedSpecs/all/*.json',\n        'data/ExtendedSpecs/ap-northeast-1/*.json',\n        'data/ExtendedSpecs/ap-northeast-2/*.json',\n        'data/ExtendedSpecs/ap-northeast-3/*.json',\n        'data/ExtendedSpecs/ap-south-1/*.json',\n        'data/ExtendedSpecs/ap-southeast-1/*.json',\n        'data/ExtendedSpecs/ap-southeast-2/*.json',\n        'data/ExtendedSpecs/ca-central-1/*.json',\n        'data/ExtendedSpecs/eu-central-1/*.json',\n        'data/ExtendedSpecs/eu-north-1/*.json',\n        'data/ExtendedSpecs/eu-west-1/*.json',\n        'data/ExtendedSpecs/eu-west-2/*.json',\n        'data/ExtendedSpecs/eu-west-3/*.json',\n        'data/ExtendedSpecs/sa-east-1/*.json',\n        'data/ExtendedSpecs/us-east-1/*.json',\n        'data/ExtendedSpecs/us-east-2/*.json',\n        'data/ExtendedSpecs/us-gov-east-1/*.json',\n        'data/ExtendedSpecs/us-gov-west-1/*.json',\n        'data/ExtendedSpecs/us-west-1/*.json',\n        'data/ExtendedSpecs/us-west-2/*.json',\n        'data/CfnLintCli/config/schema.json'\n    ]},\n    packages=find_packages('src'),\n    zip_safe=False,\n    install_requires=[\n        'pyyaml',\n        'six~=1.11',\n        'requests>=2.15.0',\n        'aws-sam-translator>=1.10.0',\n        'jsonpatch',\n        'jsonschema~=2.6',\n        'pathlib2>=2.3.0;python_version<\"3.4\"'\n    ],\n    python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',\n    entry_points={\n        'console_scripts': [\n            'cfn-lint = cfnlint.__main__:main'\n        ]\n    },\n    license='MIT no attribution',\n    test_suite=\"unittest\",\n    classifiers=[\n        'Development Status :: 5 - Production/Stable',\n        'Intended Audience :: Developers',\n        'License :: OSI Approved :: MIT License',\n        'Natural Language :: English',\n        'Operating System :: OS Independent',\n        'Programming Language :: Python :: 2',\n        'Programming Language :: Python :: 2.7',\n        'Programming Language :: Python :: 3',\n        'Programming Language :: Python :: 3.4',\n        'Programming Language :: Python :: 3.5',\n        'Programming Language :: Python :: 3.6',\n        'Programming Language :: Python :: 3.7',\n    ],\n)\n", "path": "setup.py"}, {"content": "\"\"\"\n  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this\n  software and associated documentation files (the \"Software\"), to deal in the Software\n  without restriction, including without limitation the rights to use, copy, modify,\n  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n  permit persons to whom the Software is furnished to do so.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\"\"\"\nimport six\nfrom cfnlint import CloudFormationLintRule\nfrom cfnlint import RuleMatch\n\n\nclass SubUnneeded(CloudFormationLintRule):\n    \"\"\"Check if Sub is using a variable\"\"\"\n    id = 'W1020'\n    shortdesc = 'Sub isn\\'t needed if it doesn\\'t have a variable defined'\n    description = 'Checks sub strings to see if a variable is defined.'\n    source_url = 'https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html'\n    tags = ['functions', 'sub']\n\n    def _test_string(self, cfn, sub_string, tree):\n        \"\"\"Test if a string has appropriate parameters\"\"\"\n\n        matches = []\n        string_params = cfn.get_sub_parameters(sub_string)\n\n        if not string_params:\n            message = 'Fn::Sub isn\\'t needed because there are no variables at {0}'\n            matches.append(RuleMatch(\n                tree, message.format('/'.join(map(str, tree)))))\n\n        return matches\n\n    def match(self, cfn):\n        \"\"\"Check CloudFormation Join\"\"\"\n\n        matches = []\n\n        sub_objs = cfn.search_deep_keys('Fn::Sub')\n\n        for sub_obj in sub_objs:\n            sub_value_obj = sub_obj[-1]\n            tree = sub_obj[:-1]\n            if isinstance(sub_value_obj, six.string_types):\n                matches.extend(self._test_string(cfn, sub_value_obj, tree))\n            elif isinstance(sub_value_obj, list):\n                if len(sub_value_obj) == 2:\n                    sub_string = sub_value_obj[0]\n                    matches.extend(self._test_string(cfn, sub_string, tree + [0]))\n\n        return matches\n", "path": "src/cfnlint/rules/functions/SubUnneeded.py"}], "after_files": [{"content": "\"\"\"\n  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this\n  software and associated documentation files (the \"Software\"), to deal in the Software\n  without restriction, including without limitation the rights to use, copy, modify,\n  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n  permit persons to whom the Software is furnished to do so.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\"\"\"\nimport codecs\nimport re\nfrom setuptools import find_packages\nfrom setuptools import setup\n\n\ndef get_version(filename):\n    with codecs.open(filename, 'r', 'utf-8') as fp:\n        contents = fp.read()\n    return re.search(r\"__version__ = ['\\\"]([^'\\\"]+)['\\\"]\", contents).group(1)\n\n\nversion = get_version('src/cfnlint/version.py')\n\n\nwith open('README.md') as f:\n    readme = f.read()\n\nsetup(\n    name='cfn-lint',\n    version=version,\n    description=('checks cloudformation for practices and behaviour \\\n        that could potentially be improved'),\n    long_description=readme,\n    long_description_content_type=\"text/markdown\",\n    keywords='aws, lint',\n    author='kddejong',\n    author_email='kddejong@amazon.com',\n    url='https://github.com/aws-cloudformation/cfn-python-lint',\n    package_dir={'': 'src'},\n    package_data={'cfnlint': [\n        'data/CloudSpecs/*.json',\n        'data/AdditionalSpecs/*.json',\n        'data/Serverless/*.json',\n        'data/ExtendedSpecs/all/*.json',\n        'data/ExtendedSpecs/ap-northeast-1/*.json',\n        'data/ExtendedSpecs/ap-northeast-2/*.json',\n        'data/ExtendedSpecs/ap-northeast-3/*.json',\n        'data/ExtendedSpecs/ap-south-1/*.json',\n        'data/ExtendedSpecs/ap-southeast-1/*.json',\n        'data/ExtendedSpecs/ap-southeast-2/*.json',\n        'data/ExtendedSpecs/ca-central-1/*.json',\n        'data/ExtendedSpecs/eu-central-1/*.json',\n        'data/ExtendedSpecs/eu-north-1/*.json',\n        'data/ExtendedSpecs/eu-west-1/*.json',\n        'data/ExtendedSpecs/eu-west-2/*.json',\n        'data/ExtendedSpecs/eu-west-3/*.json',\n        'data/ExtendedSpecs/sa-east-1/*.json',\n        'data/ExtendedSpecs/us-east-1/*.json',\n        'data/ExtendedSpecs/us-east-2/*.json',\n        'data/ExtendedSpecs/us-gov-east-1/*.json',\n        'data/ExtendedSpecs/us-gov-west-1/*.json',\n        'data/ExtendedSpecs/us-west-1/*.json',\n        'data/ExtendedSpecs/us-west-2/*.json',\n        'data/CfnLintCli/config/schema.json'\n    ]},\n    packages=find_packages('src'),\n    zip_safe=False,\n    install_requires=[\n        'pyyaml',\n        'six~=1.11',\n        'requests>=2.15.0,<=2.21.0',\n        'aws-sam-translator>=1.10.0',\n        'jsonpatch',\n        'jsonschema~=2.6',\n        'pathlib2>=2.3.0;python_version<\"3.4\"'\n    ],\n    python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',\n    entry_points={\n        'console_scripts': [\n            'cfn-lint = cfnlint.__main__:main'\n        ]\n    },\n    license='MIT no attribution',\n    test_suite=\"unittest\",\n    classifiers=[\n        'Development Status :: 5 - Production/Stable',\n        'Intended Audience :: Developers',\n        'License :: OSI Approved :: MIT License',\n        'Natural Language :: English',\n        'Operating System :: OS Independent',\n        'Programming Language :: Python :: 2',\n        'Programming Language :: Python :: 2.7',\n        'Programming Language :: Python :: 3',\n        'Programming Language :: Python :: 3.4',\n        'Programming Language :: Python :: 3.5',\n        'Programming Language :: Python :: 3.6',\n        'Programming Language :: Python :: 3.7',\n    ],\n)\n", "path": "setup.py"}, {"content": "\"\"\"\n  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this\n  software and associated documentation files (the \"Software\"), to deal in the Software\n  without restriction, including without limitation the rights to use, copy, modify,\n  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n  permit persons to whom the Software is furnished to do so.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\"\"\"\nimport six\nfrom cfnlint import CloudFormationLintRule\nfrom cfnlint import RuleMatch\n\n\nclass SubUnneeded(CloudFormationLintRule):\n    \"\"\"Check if Sub is using a variable\"\"\"\n    id = 'W1020'\n    shortdesc = 'Sub isn\\'t needed if it doesn\\'t have a variable defined'\n    description = 'Checks sub strings to see if a variable is defined.'\n    source_url = 'https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html'\n    tags = ['functions', 'sub']\n\n    def _test_string(self, cfn, sub_string, tree):\n        \"\"\"Test if a string has appropriate parameters\"\"\"\n\n        matches = []\n        string_params = cfn.get_sub_parameters(sub_string)\n\n        if not string_params:\n            message = 'Fn::Sub isn\\'t needed because there are no variables at {0}'\n            matches.append(RuleMatch(\n                tree, message.format('/'.join(map(str, tree)))))\n\n        return matches\n\n    def match(self, cfn):\n        \"\"\"Check CloudFormation Join\"\"\"\n\n        matches = []\n\n        sub_objs = cfn.transform_pre.get('Fn::Sub')\n\n        for sub_obj in sub_objs:\n            sub_value_obj = sub_obj[-1]\n            tree = sub_obj[:-1]\n            if isinstance(sub_value_obj, six.string_types):\n                matches.extend(self._test_string(cfn, sub_value_obj, tree))\n            elif isinstance(sub_value_obj, list):\n                if len(sub_value_obj) == 2:\n                    sub_string = sub_value_obj[0]\n                    matches.extend(self._test_string(cfn, sub_string, tree + [0]))\n\n        return matches\n", "path": "src/cfnlint/rules/functions/SubUnneeded.py"}]}