Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py

changeset 4514
e410e76d6538
parent 4509
7797ee4a45f9
child 4556
25d1fa006bf0
equal deleted inserted replaced
4512:23e8b848efb0 4514:e410e76d6538
434 self.__batch = False 434 self.__batch = False
435 self.check() 435 self.check()
436 else: 436 else:
437 self.__batch = True 437 self.__batch = True
438 self.checkBatch() 438 self.checkBatch()
439 439
440 def __modifyOptions(self, source):
441 """
442 Private method to modify the options based on eflag: entries.
443
444 This method looks for comment lines like '# eflag: noqa = M601'
445 at the end of the source in order to extend the list of excluded
446 messages for one file only.
447
448 @param source source text (list of str or str)
449 @return list of checker options
450 """
451 options = self.__options[:]
452 flags = Utilities.extractFlags(source)
453 if "noqa" in flags and isinstance(flags["noqa"], str):
454 excludeMessages = \
455 options[0].strip().rstrip(",")
456 if excludeMessages:
457 excludeMessages += ","
458 excludeMessages += flags["noqa"]
459 options[0] = excludeMessages
460 return options
461
440 def check(self, codestring=''): 462 def check(self, codestring=''):
441 """ 463 """
442 Public method to start a style check for one file. 464 Public method to start a style check for one file.
443 465
444 The results are reported to the __processResult slot. 466 The results are reported to the __processResult slot.
483 return 505 return
484 if encoding.endswith( 506 if encoding.endswith(
485 ('-selected', '-default', '-guessed', '-ignore')): 507 ('-selected', '-default', '-guessed', '-ignore')):
486 encoding = encoding.rsplit('-', 1)[0] 508 encoding = encoding.rsplit('-', 1)[0]
487 509
510 options = self.__modifyOptions(source)
511
488 errors = [] 512 errors = []
489 self.__itms = [] 513 self.__itms = []
490 for error, itm in self.__onlyFixes.pop(self.filename, []): 514 for error, itm in self.__onlyFixes.pop(self.filename, []):
491 errors.append(error) 515 errors.append(error)
492 self.__itms.append(itm) 516 self.__itms.append(itm)
493 517
494 eol = self.__getEol(self.filename) 518 eol = self.__getEol(self.filename)
495 args = self.__options + [ 519 args = options + [
496 errors, eol, encoding, Preferences.getEditor("CreateBackupFile") 520 errors, eol, encoding, Preferences.getEditor("CreateBackupFile")
497 ] 521 ]
498 self.__finished = False 522 self.__finished = False
499 self.styleCheckService.styleCheck( 523 self.styleCheckService.styleCheck(
500 None, self.filename, source, args) 524 None, self.filename, source, args)
530 554
531 if encoding.endswith( 555 if encoding.endswith(
532 ('-selected', '-default', '-guessed', '-ignore')): 556 ('-selected', '-default', '-guessed', '-ignore')):
533 encoding = encoding.rsplit('-', 1)[0] 557 encoding = encoding.rsplit('-', 1)[0]
534 558
559 options = self.__modifyOptions(source)
560
535 errors = [] 561 errors = []
536 self.__itms = [] 562 self.__itms = []
537 for error, itm in self.__onlyFixes.pop(filename, []): 563 for error, itm in self.__onlyFixes.pop(filename, []):
538 errors.append(error) 564 errors.append(error)
539 self.__itms.append(itm) 565 self.__itms.append(itm)
540 566
541 eol = self.__getEol(filename) 567 eol = self.__getEol(filename)
542 args = self.__options + [ 568 args = options + [
543 errors, eol, encoding, 569 errors, eol, encoding,
544 Preferences.getEditor("CreateBackupFile") 570 Preferences.getEditor("CreateBackupFile")
545 ] 571 ]
546 argumentsList.append((filename, source, args)) 572 argumentsList.append((filename, source, args))
547 573

eric ide

mercurial