88def  rocrate_readme_sync (self ):
99    """ 
1010    Check if the RO-Crate description in ro-crate-metadata.json matches the README.md content. 
11-     If the --fix is set , the RO-Crate description will be updated to match the README.md content. 
11+     If not , the RO-Crate description will be automatically  updated to match the README.md content during linting . 
1212    """ 
1313
1414    passed  =  []
15-     failed  =  []
1615    ignored  =  []
1716    fixed  =  []
18-     could_fix : bool  =  False 
1917
2018    # Check if the file exists before trying to load it 
2119    metadata_file  =  Path (self .wf_path , "ro-crate-metadata.json" )
@@ -27,46 +25,35 @@ def rocrate_readme_sync(self):
2725            ignored .append ("`ro-crate-metadata.json` not found" )
2826        if  not  readme_file .exists ():
2927            ignored .append ("`README.md` not found" )
30-         return  {"passed" : passed , "failed " : failed , "ignored" : ignored }
28+         return  {"passed" : passed , "fixed " : fixed , "ignored" : ignored }
3129
3230    try :
3331        metadata_content  =  metadata_file .read_text (encoding = "utf-8" )
3432        metadata_dict  =  json .loads (metadata_content )
3533    except  json .JSONDecodeError  as  e :
3634        log .error ("Failed to decode JSON from `ro-crate-metadata.json`: %s" , e )
3735        ignored .append ("Invalid JSON in `ro-crate-metadata.json`" )
38-         return  {"passed" : passed , "failed " : failed , "ignored" : ignored }
36+         return  {"passed" : passed , "fixed " : fixed , "ignored" : ignored }
3937    readme_content  =  readme_file .read_text (encoding = "utf-8" )
4038    graph  =  metadata_dict .get ("@graph" )
39+ 
4140    if  not  graph  or  not  isinstance (graph , list ) or  not  graph [0 ] or  not  isinstance (graph [0 ], dict ):
4241        ignored .append ("Invalid RO-Crate metadata structure." )
4342    else :
4443        # Check if the 'description' key is present 
4544        if  "description"  not  in   graph [0 ]:
46-             if  "rocrate_readme_sync"  in  self .fix :
47-                 metadata_dict .get ("@graph" )[0 ]["description" ] =  readme_content 
48-                 fixed .append ("Fixed: add the same description from `README.md` to the RO-Crate metadata." )
49-             else :
50-                 ignored .append ("No description found in `ro-crate-metadata.json`." )
51-                 return  {"passed" : passed , "failed" : failed , "ignored" : ignored }
45+             metadata_dict .get ("@graph" )[0 ]["description" ] =  readme_content 
46+             fixed .append ("Fixed: add the same description from `README.md` to the RO-Crate metadata." )
5247
5348    rc_description_graph  =  metadata_dict .get ("@graph" , [{}])[0 ].get ("description" )
5449
5550    # Compare the two strings and add a linting error if they don't match 
5651    if  readme_content  !=  rc_description_graph :
57-         # If the --fix flag is set, you could overwrite the RO-Crate description with the README content: 
58-         if  "rocrate_readme_sync"  in  self .fix :
59-             metadata_dict .get ("@graph" )[0 ]["description" ] =  readme_content 
60-             fixed .append ("Fixed: add the same description from `README.md` to the RO-Crate metadata." )
61-             with  metadata_file .open ("w" , encoding = "utf-8" ) as  f :
62-                 json .dump (metadata_dict , f , indent = 4 )
63-             passed .append ("RO-Crate description matches the `README.md`." )
64-             fixed .append ("Mismatch fixed: RO-Crate description updated from `README.md`." )
65-         else :
66-             failed .append (
67-                 "The RO-Crate descriptions do not match the README.md content. Use `nf-core pipelines lint --fix rocrate_readme_sync` to update." 
68-             )
69-             could_fix  =  True 
52+         metadata_dict .get ("@graph" )[0 ]["description" ] =  readme_content 
53+         with  metadata_file .open ("w" , encoding = "utf-8" ) as  f :
54+             json .dump (metadata_dict , f , indent = 4 )
55+         passed .append ("RO-Crate description matches the `README.md`." )
56+         fixed .append ("Mismatch fixed: RO-Crate description updated from `README.md`." )
7057    else :
7158        passed .append ("RO-Crate descriptions are in sync with `README.md`." )
72-     return  {"passed" : passed , "failed"  :  failed ,  "ignored" :  ignored ,  " fixed" : fixed , "could_fix " : could_fix }
59+     return  {"passed" : passed , "fixed" : fixed , "ignored " : ignored }
0 commit comments