diff --git a/src/cfgnet/plugins/concept/flutter_plugin.py b/src/cfgnet/plugins/concept/flutter_plugin.py
new file mode 100644
index 0000000..e634224
--- /dev/null
+++ b/src/cfgnet/plugins/concept/flutter_plugin.py
@@ -0,0 +1,61 @@
+# This file is part of the CfgNet module.
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see .
+import os
+from cfgnet.plugins.file_type.yaml_plugin import YAMLPlugin
+from cfgnet.config_types.config_types import ConfigType
+
+
+class FlutterPlugin(YAMLPlugin):
+ def __init__(self):
+ super().__init__("flutter")
+
+ def is_responsible(self, abs_file_path) -> bool:
+ file_name = os.path.basename(abs_file_path)
+ return file_name == "pubspec.yaml"
+
+ # pylint: disable=too-many-return-statements
+ def get_config_type(self, option_name: str) -> ConfigType:
+ """
+ Find config type based on option name.
+
+ :param option_name: name of option
+ :return: config type
+ """
+ if option_name.endswith(("name", "description", "ref")):
+ return ConfigType.NAME
+
+ if option_name.endswith(
+ ("version", "dependencies", "dev-dependencies", "environment")
+ ):
+ return ConfigType.VERSION_NUMBER
+
+ if option_name.endswith(("exectuables", "false_secrets", "path")):
+ return ConfigType.PATH
+
+ if option_name.endswith(
+ (
+ "homepage",
+ "issue_tracker",
+ "documentation",
+ "repository",
+ "hosted",
+ "url",
+ "git",
+ "funding",
+ )
+ ):
+ return ConfigType.URL
+
+ return ConfigType.UNKNOWN
diff --git a/src/cfgnet/plugins/plugin_manager.py b/src/cfgnet/plugins/plugin_manager.py
index 3139e57..d0e2f10 100644
--- a/src/cfgnet/plugins/plugin_manager.py
+++ b/src/cfgnet/plugins/plugin_manager.py
@@ -55,6 +55,7 @@
from cfgnet.plugins.concept.cargo_plugin import CargoPlugin
from cfgnet.plugins.concept.github_actions_plugin import GitHubActionPlugin
from cfgnet.plugins.concept.gradle_plugin import GradlePlugin
+from cfgnet.plugins.concept.flutter_plugin import FlutterPlugin
class PluginManager:
@@ -91,6 +92,7 @@ class PluginManager:
CargoPlugin(),
GitHubActionPlugin(),
GradlePlugin(),
+ FlutterPlugin(),
]
file_type_plugins: List[Plugin] = [
diff --git a/tests/cfgnet/plugins/concept/test_flutter_plugin.py b/tests/cfgnet/plugins/concept/test_flutter_plugin.py
new file mode 100644
index 0000000..b7bfad7
--- /dev/null
+++ b/tests/cfgnet/plugins/concept/test_flutter_plugin.py
@@ -0,0 +1,57 @@
+# This file is part of the CfgNet module.
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see .
+
+import os
+
+import pytest
+
+from cfgnet.plugins.concept.flutter_plugin import FlutterPlugin
+from cfgnet.config_types.config_types import ConfigType
+from tests.utility.id_creator import make_id
+
+
+@pytest.fixture(name="get_plugin")
+def get_plugin_():
+ plugin = FlutterPlugin()
+ return plugin
+
+
+def test_is_responsible(get_plugin):
+ plugin = get_plugin
+
+ assert plugin.is_responsible("tests/files/pubspec.yaml")
+ assert not plugin.is_responsible("tests/files/pubspec.yml")
+
+
+def test_config_types(get_plugin):
+ plugin = get_plugin
+ file = os.path.abspath("tests/files/pubspec.yaml")
+ artifact = plugin.parse_file(file, "pubspec.yaml")
+ nodes = artifact.get_nodes()
+
+ for node in nodes:
+ print(node, node.config_type)
+
+ version_node = next(filter(lambda x: x.id == make_id("pubspec.yaml", "version", "1.0.0"), nodes))
+ name_node = next(filter(lambda x: x.id == make_id("pubspec.yaml", "name", "my_flutter_app"), nodes))
+ url_node = next(filter(lambda x: x.id == make_id("pubspec.yaml", "homepage", "https://example.com"), nodes))
+ boolean_node = next(filter(lambda x: x.id == make_id("pubspec.yaml", "flutter", "uses-material-design", "true"), nodes))
+ dep_node = next(filter(lambda x: x.id == make_id("pubspec.yaml", "dev_dependencies", "test", ">=1.15.0 <2.0.0"), nodes))
+
+ assert version_node.config_type == ConfigType.VERSION_NUMBER
+ assert boolean_node.config_type == ConfigType.BOOLEAN
+ assert dep_node.config_type == ConfigType.VERSION_NUMBER
+ assert name_node.config_type == ConfigType.NAME
+ assert url_node.config_type == ConfigType.URL
diff --git a/tests/cfgnet/plugins/test_plugin_manager.py b/tests/cfgnet/plugins/test_plugin_manager.py
index 99f1031..f900898 100644
--- a/tests/cfgnet/plugins/test_plugin_manager.py
+++ b/tests/cfgnet/plugins/test_plugin_manager.py
@@ -19,7 +19,7 @@
def test_get_all_plugins():
all_plugins = PluginManager.get_plugins()
- assert len(all_plugins) == 30
+ assert len(all_plugins) == 31
def test_get_responsible_plugin():
@@ -55,6 +55,7 @@ def test_get_responsible_plugin():
cargo_plugin = PluginManager.get_responsible_plugin(plugins, "path/to/Cargo.toml")
github_action_plugin = PluginManager.get_responsible_plugin(plugins, ".github/workflows/test.yml")
gradle_plugin = PluginManager.get_responsible_plugin(plugins, "path/to/gradle.properties")
+ flutter_plugin = PluginManager.get_responsible_plugin(plugins, "path/to/pubspec.yaml")
assert docker_plugin.concept_name == "docker"
assert maven_plugin.concept_name == "maven"
@@ -86,3 +87,4 @@ def test_get_responsible_plugin():
assert cargo_plugin.concept_name == "cargo"
assert github_action_plugin.concept_name == "github-action"
assert gradle_plugin.concept_name == "gradle"
+ assert flutter_plugin.concept_name == "flutter"
diff --git a/tests/files/pubspec.yaml b/tests/files/pubspec.yaml
new file mode 100644
index 0000000..a372c68
--- /dev/null
+++ b/tests/files/pubspec.yaml
@@ -0,0 +1,18 @@
+name: my_flutter_app
+description: A new Flutter project.
+version: 1.0.0
+homepage: https://example.com
+
+environment:
+ sdk: '^3.2.0'
+
+dependencies:
+ efts: ^2.0.4
+ transmogrify: ^0.4.0
+
+dev_dependencies:
+ test: '>=1.15.0 <2.0.0'
+
+flutter:
+ uses-material-design: true
+