Completed
Push — master ( bb5487...4fc1d0 )
by Manas
13:01 queued 05:18
created

st2api.controllers.exp.ResourceController._get_all()   F

Complexity

Conditions 17

Size

Total Lines 82

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 82
rs 2.0647
cc 17

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

Complexity

Complex classes like st2api.controllers.exp.ResourceController._get_all() often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
2
# contributor license agreements.  See the NOTICE file distributed with
3
# this work for additional information regarding copyright ownership.
4
# The ASF licenses this file to You under the Apache License, Version 2.0
5
# (the "License"); you may not use this file except in compliance with
6
# the License.  You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
16
from st2api.controllers.exp.actionalias import ActionAliasController
17
from st2api.controllers.exp.aliasexecution import ActionAliasExecutionController
18
from st2api.controllers.exp.validation import ValidationController
19
20
21
class RootController(object):
22
23
    # Here for backward compatibility reasons
24
    # Deprecated. Use /v1/ instead.
25
    actionalias = ActionAliasController()
26
    aliasexecution = ActionAliasExecutionController()
27
28
    # Experimental
29
    validation = ValidationController()
30