Completed
Push — master ( e81db1...a7ad2f )
by Björn
17s queued 13s
created

gvm.protocols.gmpv214   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 68
Duplicated Lines 33.82 %

Importance

Changes 0
Metric Value
wmc 2
eloc 23
dl 23
loc 68
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Gmp.__init__() 10 10 1
A Gmp.get_protocol_version() 8 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
# -*- coding: utf-8 -*-
2
# Copyright (C) 2020 Greenbone Networks GmbH
3
#
4
# SPDX-License-Identifier: GPL-3.0-or-later
5
#
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19
# pylint: disable=too-many-lines,redefined-builtin
20
21
"""
22
Module for communication with gvmd in
23
`Greenbone Management Protocol version 21.04`_
24
25
.. _Greenbone Management Protocol version 21.04:
26
    https://docs.greenbone.net/API/GMP/gmp-21.04.html
27
"""
28
29
from typing import Any, Callable, Optional
30
31
from gvm.protocols.gmpv214.gmpv214 import GmpV214Mixin
32
from gvm.protocols.gmpv208.gmpv208 import GmpV208Mixin
33
from gvm.protocols.gmpv9.gmpv9 import GmpV9Mixin
34
from gvm.protocols.gmpv8.gmpv8 import GmpV8Mixin
35
from gvm.protocols.gmpv7.gmpv7 import GmpV7Mixin
36
from gvm.connections import GvmConnection
37
38
39
from . import types
40
from .types import *  # pylint: disable=unused-wildcard-import, wildcard-import
41
42
PROTOCOL_VERSION = (21, 4)
43
44
45 View Code Duplication
class Gmp(GmpV214Mixin, GmpV208Mixin, GmpV9Mixin, GmpV8Mixin, GmpV7Mixin):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
46
47
    types = types
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable types does not seem to be defined.
Loading history...
48
49
    def __init__(
50
        self,
51
        connection: GvmConnection,
52
        *,
53
        transform: Optional[Callable[[str], Any]] = None
54
    ):
55
        super().__init__(connection, transform=transform)
56
57
        # Is authenticated on gvmd
58
        self._authenticated = False
59
60
    @staticmethod
61
    def get_protocol_version() -> tuple:
62
        """Determine the Greenbone Management Protocol version.
63
64
        Returns:
65
            tuple: Implemented version of the Greenbone Management Protocol
66
        """
67
        return PROTOCOL_VERSION
68