#1349 linter enhancements
Merged 3 years ago by praiskup. Opened 3 years ago by praiskup.
Unknown source linter-ehnancements  into  master

file modified
+1 -1
@@ -87,7 +87,7 @@

      container=$(docker run --rm -v "$PWD":/workdir:Z -d "$image" sleep 1800)

      cleanup_actions+=( "docker kill $container" )

      for package; do

-       docker exec "$container" bash -c "cd /workdir/$package && ../build_aux/linter --compare-against $DIFF_AGAINST"

+       docker exec "$container" bash -c "cd /workdir/$package && ../build_aux/linter --print-fixed-errors --compare-against $DIFF_AGAINST"

      done

  }

  

file modified
+32 -6
@@ -20,6 +20,18 @@

  CSDIFF_PYLINT = os.path.realpath(os.path.join(os.path.dirname(__file__),

                                                'csdiff-pylint'))

  

+ def _run_csdiff(old, new, msg):

+     popen_diff = Popen(['csdiff', old, new],

+                        stdout=PIPE)

+     diff = popen_diff.communicate()[0].decode('utf-8')

+     if diff:

+         print("============")

+         print(msg)

+         print("============")

+         print()

+         sys.stdout.write(diff)

+     return int(bool(diff))

+ 

  

  def file_type(filename):

      """
@@ -270,14 +282,15 @@

                  finally:

                      os.chdir(oldcwd)

  

-             popen_diff = Popen(['csdiff', old_report, new_report],

-                                stdout=PIPE)

-             diff = popen_diff.communicate()[0].decode('utf-8')

-             sys.stdout.write(diff)

-             sys.exit(bool(diff))

+             if self.options.print_fixed_errors:

+                 _run_csdiff(new_report, old_report, "Fixed warnings")

+ 

+             sys.exit(_run_csdiff(old_report, new_report, "Added warnings"))

+ 

          finally:

              log.debug("removing workdir %s", self.workdir)

-             shutil.rmtree(self.workdir)

+             if not self.options.no_cleanup:

+                 shutil.rmtree(self.workdir)

  

  

  def _get_arg_parser():
@@ -292,6 +305,19 @@

          "--log-level",

          default='error',

          help="The python logging level, e.g. debug, error, ...")

+     parser.add_argument(

+         "--no-cleanup",

+         action='store_true',

+         default=False,

+         help=("Keep the temporary working directory, you can use the "

+               "--log-level=info switch to see where it is created"),

+     )

+     parser.add_argument(

+         "--print-fixed-errors",

+         action='store_true',

+         default=False,

+         help="Also print defects which were fixed by the changes",

+     )

      return parser

  

  

no initial comment

I am not sure if it is obvious what this option does. Wouldn't something like --no-clean be better?

I think we can define this on top-level

rebased onto c5653767cf7e81ae575d4fe4f4cde615d9aba110

3 years ago

rebased onto f31018f

3 years ago

thanks for taking a look!

Pull-Request has been merged by praiskup

3 years ago