private void ReportInvalidBase(Arg arg)
 {
     Eval.ReportDiagnostics(Eval.Module.Uri,
                            new DiagnosticsEntry(
                                Resources.InheritNonClass.FormatInvariant(arg.ToCodeString(Eval.Ast, CodeFormattingOptions.Traditional)),
                                Eval.GetLocation(arg)?.Span ?? default,
                                Diagnostics.ErrorCodes.InheritNonClass,
                                Severity.Warning,
                                DiagnosticSource.Analysis
                                ));
 }
 private void HandleGlobal(GlobalStatement node)
 {
     foreach (var nex in node.Names)
     {
         var m = Eval.LookupNameInScopes(nex.Name, out _, LookupOptions.Global);
         if (m == null)
         {
             _diagnostics.Add(new DiagnosticsEntry(
                                  Resources.ErrorVariableNotDefinedGlobally.FormatInvariant(nex.Name),
                                  Eval.GetLocation(nex).Span, ErrorCodes.VariableNotDefinedGlobally, Severity.Warning, DiagnosticSource.Linter));
         }
     }
 }
        private void CheckValidFunction(IPythonFunctionType function, IReadOnlyList <IParameterInfo> parameters)
        {
            // Don't give diagnostics on functions defined in metaclasses
            if (_self.IsMetaclass())
            {
                return;
            }

            // Static methods don't need any diagnostics
            if (function.IsStatic)
            {
                return;
            }

            // Lambdas never get a self/cls argument.
            if (function.IsLambda())
            {
                return;
            }

            // Error in parameters, don't lint
            if (FunctionDefinition.Body == null)
            {
                return;
            }

            // Otherwise, functions defined in classes must have at least one argument
            if (parameters.IsNullOrEmpty())
            {
                var funcLoc = Eval.GetLocation(FunctionDefinition.NameExpression);
                ReportFunctionParams(Resources.NoMethodArgument, ErrorCodes.NoMethodArgument, funcLoc);
                return;
            }

            var param    = parameters[0].Name;
            var paramLoc = Eval.GetLocation(FunctionDefinition.Parameters[0]);

            // If it is a class method check for cls
            if (function.IsClassMethod && !param.Equals("cls"))
            {
                ReportFunctionParams(Resources.NoClsArgument, ErrorCodes.NoClsArgument, paramLoc);
            }

            // If it is a method check for self
            if (!function.IsClassMethod && !param.Equals("self"))
            {
                ReportFunctionParams(Resources.NoSelfArgument, ErrorCodes.NoSelfArgument, paramLoc);
            }
        }