prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Add type checking to role metadata in rule 701 MetaMainHasInfoRule
  
  
  </issue>
  <code>
  [start of lib/ansiblelint/rules/MetaMainHasInfoRule.py]
  1 # Copyright (c) 2016, Will Thames and contributors
  2 # Copyright (c) 2018, Ansible Project
  3 
  4 from ansiblelint import AnsibleLintRule
  5 
  6 
  7 class MetaMainHasInfoRule(AnsibleLintRule):
  8     id = '701'
  9     shortdesc = 'meta/main.yml should contain relevant info'
  10     info = [
  11         'author',
  12         'description',
  13         'license',
  14         'min_ansible_version',
  15         'platforms',
  16     ]
  17     description = (
  18         'meta/main.yml should contain: ``{}``'.format(', '.join(info))
  19     )
  20     severity = 'HIGH'
  21     tags = ['metadata']
  22     version_added = 'v4.0.0'
  23 
  24     def matchplay(self, file, data):
  25         if file['type'] != 'meta':
  26             return False
  27 
  28         galaxy_info = data.get('galaxy_info', None)
  29         if not galaxy_info:
  30             return [({'meta/main.yml': data},
  31                     "No 'galaxy_info' found")]
  32 
  33         results = []
  34         for info in self.info:
  35             if not galaxy_info.get(info, None):
  36                 results.append(({'meta/main.yml': data},
  37                                 'Role info should contain %s' % info))
  38 
  39         platforms = galaxy_info.get('platforms', None)
  40         if platforms:
  41             for platform in platforms:
  42                 if not platform.get('name', None):
  43                     results.append(({'meta/main.yml': data},
  44                                     'Platform should contain name'))
  45 
  46         return results
  47
  [end of lib/ansiblelint/rules/MetaMainHasInfoRule.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/lib/ansiblelint/rules/MetaMainHasInfoRule.py b/lib/ansiblelint/rules/MetaMainHasInfoRule.py
  --- a/lib/ansiblelint/rules/MetaMainHasInfoRule.py
  +++ b/lib/ansiblelint/rules/MetaMainHasInfoRule.py
  @@ -1,6 +1,8 @@
   # Copyright (c) 2016, Will Thames and contributors
   # Copyright (c) 2018, Ansible Project
   
  +import six
  +
   from ansiblelint import AnsibleLintRule
   
   
  @@ -36,11 +38,29 @@
                   results.append(({'meta/main.yml': data},
                                   'Role info should contain %s' % info))
   
  +        for info in ['author', 'description']:
  +            if not galaxy_info.get(info):
  +                continue
  +            if not isinstance(galaxy_info.get(info), six.string_types):
  +                results.append(({'meta/main.yml': data},
  +                                '%s should be a string' % info))
  +
           platforms = galaxy_info.get('platforms', None)
  -        if platforms:
  -            for platform in platforms:
  -                if not platform.get('name', None):
  -                    results.append(({'meta/main.yml': data},
  -                                    'Platform should contain name'))
  +        if not platforms:
  +            return results
  +
  +        if not isinstance(platforms, list):
  +            results.append(({'meta/main.yml': data},
  +                            'Platforms should be a list of dictionaries'))
  +            return results
  +
  +        for platform in platforms:
  +            if not isinstance(platform, dict):
  +                results.append(({'meta/main.yml': data},
  +                                'Platforms should be a list of dictionaries'))
  +                continue
  +            if not platform.get('name', None):
  +                results.append(({'meta/main.yml': data},
  +                                'Platform should contain name'))
   
           return results
  
verification_info: {"golden_diff": "diff --git a/lib/ansiblelint/rules/MetaMainHasInfoRule.py b/lib/ansiblelint/rules/MetaMainHasInfoRule.py\n--- a/lib/ansiblelint/rules/MetaMainHasInfoRule.py\n+++ b/lib/ansiblelint/rules/MetaMainHasInfoRule.py\n@@ -1,6 +1,8 @@\n # Copyright (c) 2016, Will Thames and contributors\n # Copyright (c) 2018, Ansible Project\n \n+import six\n+\n from ansiblelint import AnsibleLintRule\n \n \n@@ -36,11 +38,29 @@\n                 results.append(({'meta/main.yml': data},\n                                 'Role info should contain %s' % info))\n \n+        for info in ['author', 'description']:\n+            if not galaxy_info.get(info):\n+                continue\n+            if not isinstance(galaxy_info.get(info), six.string_types):\n+                results.append(({'meta/main.yml': data},\n+                                '%s should be a string' % info))\n+\n         platforms = galaxy_info.get('platforms', None)\n-        if platforms:\n-            for platform in platforms:\n-                if not platform.get('name', None):\n-                    results.append(({'meta/main.yml': data},\n-                                    'Platform should contain name'))\n+        if not platforms:\n+            return results\n+\n+        if not isinstance(platforms, list):\n+            results.append(({'meta/main.yml': data},\n+                            'Platforms should be a list of dictionaries'))\n+            return results\n+\n+        for platform in platforms:\n+            if not isinstance(platform, dict):\n+                results.append(({'meta/main.yml': data},\n+                                'Platforms should be a list of dictionaries'))\n+                continue\n+            if not platform.get('name', None):\n+                results.append(({'meta/main.yml': data},\n+                                'Platform should contain name'))\n \n         return results\n", "issue": "Add type checking to role metadata in rule 701 MetaMainHasInfoRule\n\n", "before_files": [{"content": "# Copyright (c) 2016, Will Thames and contributors\n# Copyright (c) 2018, Ansible Project\n\nfrom ansiblelint import AnsibleLintRule\n\n\nclass MetaMainHasInfoRule(AnsibleLintRule):\n    id = '701'\n    shortdesc = 'meta/main.yml should contain relevant info'\n    info = [\n        'author',\n        'description',\n        'license',\n        'min_ansible_version',\n        'platforms',\n    ]\n    description = (\n        'meta/main.yml should contain: ``{}``'.format(', '.join(info))\n    )\n    severity = 'HIGH'\n    tags = ['metadata']\n    version_added = 'v4.0.0'\n\n    def matchplay(self, file, data):\n        if file['type'] != 'meta':\n            return False\n\n        galaxy_info = data.get('galaxy_info', None)\n        if not galaxy_info:\n            return [({'meta/main.yml': data},\n                    \"No 'galaxy_info' found\")]\n\n        results = []\n        for info in self.info:\n            if not galaxy_info.get(info, None):\n                results.append(({'meta/main.yml': data},\n                                'Role info should contain %s' % info))\n\n        platforms = galaxy_info.get('platforms', None)\n        if platforms:\n            for platform in platforms:\n                if not platform.get('name', None):\n                    results.append(({'meta/main.yml': data},\n                                    'Platform should contain name'))\n\n        return results\n", "path": "lib/ansiblelint/rules/MetaMainHasInfoRule.py"}]}