Showing 1,088 of 2,665 total issues
Function increment
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def increment(self, method=None, url=None, response=None, error=None,
Function add_metaclass
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_metaclass(metaclass):
"""Class decorator for creating a class with a metaclass."""
def wrapper(cls):
orig_vars = cls.__dict__.copy()
slots = orig_vars.get('__slots__')
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _make_request
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _make_request(self, conn, method, url, timeout=_Default, chunked=False,
Function _cert_array_from_pem
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _cert_array_from_pem(pem_bundle):
"""
Given a bundle of certs in PEM format, turns them into a CFArray of certs
that can be used to validate a cert chain.
"""
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function create_data
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def create_data(self, df_allmetrics):
"""Use x, mean, stddev to generate z scores and 3stddev flags via some pandas manipulation.
Returning two dictionaries of dimensions and measures, one for each chart.
:param df_allmetrics <pd.DataFrame>: pandas dataframe with latest data from api/v1/allmetrics.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_data_per_code_family
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_data_per_code_family(self, raw_data):
data = defaultdict(int)
for code, value in raw_data['total_status_code_count'].items():
code_prefix = code[0]
if code_prefix == '1':
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function write_to_file
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def write_to_file(path, md, meta_yaml, sidebar_label, community, mode='default'):
Method SNMP.Init
has 6 return statements (exceeds 4 allowed). Open
func (s *SNMP) Init() error {
err := s.validateConfig()
if err != nil {
s.Errorf("config validation failed: %v", err)
return err
Function parseWhoisInfoExpirationDate
has 6 return statements (exceeds 4 allowed). Open
func parseWhoisInfoExpirationDate(info *whoisparser.WhoisInfo) (float64, error) {
if info == nil || info.Domain == nil {
return 0, errors.New("nil Whois Info")
}
Method torControlClient.getInfo
has 6 return statements (exceeds 4 allowed). Open
func (c *torControlClient) getInfo(keywords ...string) ([]byte, error) {
// https://spec.torproject.org/control-spec/commands.html#getinfo
if len(keywords) == 0 {
return nil, errors.New("no keywords specified")
Method Manager.dyncfgConfigRestart
has 6 return statements (exceeds 4 allowed). Open
func (m *Manager) dyncfgConfigRestart(fn functions.Function) {
id := fn.Args[0]
mn, jn, ok := extractModuleJobName(id)
if !ok {
m.Warningf("dyncfg: restart: could not extract module from id (%s)", id)
Function doMetaGKEHTTPReq
has 6 return statements (exceeds 4 allowed). Open
func doMetaGKEHTTPReq(client *http.Client, url string) (string, error) {
req, err := http.NewRequest(http.MethodGet, url, nil)
if err != nil {
return "", err
}
Method tcpClient.getStatus
has 6 return statements (exceeds 4 allowed). Open
func (c *tcpClient) getStatus() (*status, error) {
client, err := fcgiclient.DialTimeout("tcp", c.address, c.timeout)
if err != nil {
return nil, fmt.Errorf("error on connecting to address '%s': %v", c.address, err)
}
Method Consul.collect
has 6 return statements (exceeds 4 allowed). Open
func (c *Consul) collect() (map[string]int64, error) {
if c.cfg == nil {
if err := c.collectConfiguration(); err != nil {
return nil, err
}
Method OracleDB.collect
has 6 return statements (exceeds 4 allowed). Open
func (o *OracleDB) collect() (map[string]int64, error) {
if o.db == nil {
if err := o.openConnection(); err != nil {
return nil, fmt.Errorf("failed to open connection: %v", err)
}
Function validateComposeConfig
has 6 return statements (exceeds 4 allowed). Open
func validateComposeConfig(rules []ComposeRuleConfig) error {
if len(rules) == 0 {
return errors.New("empty config, need least 1 rule")
}
for i, rule := range rules {
Function parsePostqueueOutput
has 6 return statements (exceeds 4 allowed). Open
func parsePostqueueOutput(bs []byte) (*postqueueStats, error) {
if len(bs) == 0 {
return nil, errors.New("empty postqueue output")
}
Method Manager.dyncfgConfigAdd
has 6 return statements (exceeds 4 allowed). Open
func (m *Manager) dyncfgConfigAdd(fn functions.Function) {
if len(fn.Args) < 3 {
m.Warningf("dyncfg: add: missing required arguments, want 3 got %d", len(fn.Args))
m.dyncfgRespf(fn, 400, "Missing required arguments. Need at least 3, but got %d.", len(fn.Args))
return
Method Client.get
has 6 return statements (exceeds 4 allowed). Open
func (c *Client) get(command string, stopRead stopReadFunc) (output []string, err error) {
var num int
var maxLinesErr error
err = c.Command(command, func(bytes []byte) bool {
line := string(bytes)
Method beanstalkClient.query
has 6 return statements (exceeds 4 allowed). Open
func (c *beanstalkClient) query(command string) (string, []byte, error) {
var resp string
var length int
var body []byte
var err error